-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemp Data.txt
More file actions
93 lines (68 loc) · 2.79 KB
/
Copy pathTemp Data.txt
File metadata and controls
93 lines (68 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def format_data(data):
# Country Activity Age Sex_F Sex_M Time_Afternoon Time_Evening Time_Morning Time_Night
country_encoding = {'USA' : 0.04010025,'BRAZIL': 0.36,'AUSTRALIA': 0.27272727, 'SOUTH AFRICA': 0.20465116, 'BAHAMAS' : 0.07692308, 'MEXICO' :0.49999999,
'REUNION' : 0.46153846,'EGYPT' : 0.24990115,'NEW ZEALAND' : 0.18749999,'NEW CALEDONIA' : 0.3999681 , 'MOZAMBIQUE' : 0.18181635,
'FIJI' : 0.29998044,'PAPUA NEW GUINEA': 0.49995576}
activity_encoding = {'Standing':0.08474576, 'Surfing':0.05641026, 'Swimming': 0.27574751, 'Walking': 0.07692347, 'Wading':0.07142857,
'Spearfishing': 0.15740741, 'Snorkeling': 0.19565217, 'Fishing': 0.02272727, 'Kayaking': 0.2826087 ,
'Body boarding': 0.10000512 , 'Free diving': 0.05, 'Boogie boarding': 0.26666656, 'Diving': 0.16216216,
'Body surfing': 0.27272132, 'Windsurfing': 0.0833343, 'Boogie Boarding': 0.3 , 'Scuba diving': 0.23076923,
'Treading water': 0.55, 'Bathing': 0.14149755}
country = country_encoding[data[0]]
activity= activity_encoding[data[1]]
X = [country, activity, data[2]]
if( data[3] == 'M' ):
X.append([0, 1])
else:
X.append([1, 0])
if( data[5] == 'Afternoon' ):
X.append([1, 0, 0, 0])
elif( data[5] == 'Evening' ):
X.append([0, 1, 0, 0])
elif( data[5] == 'Morning' ):
X.append([0, 0, 1, 0])
else:
X.append([0, 0, 0, 1])
X = np.array(X)
return X
@app.route('/gamepage', methods=['POST'])
def game_page():
if request.method == 'POST':
response = (request.get_json()) # parse as JSON
print(response)
session['response'] = response
return 'Sucesss', 200
print('HEllo')
return render_template('game.html')
def mlmodel_page():
pickle_in = open("classiferShark.pickle", "rb")
classifier = pickle.load(pickle_in)
data = session.get("response",None)
X = format_data(data)
prediction = classifier.fit(X)
pickle_in.close()
return render_template('mlmodel.html', data=prediction)
if (nextTextNodeId == -1) {
console.log("last page!")
fetch('/hello', {
// Declare what type of data we're sending
headers: {
'Content-Type': 'application/json'
},
// Specify the method
method: 'POST',
// A JSON payload
body: JSON.stringify({
"greeting": "Hello from the browser!"
})
}).then(function (response) { // At this point, Flask has printed our JSON
return response.text();
}).then(function (text) {
console.log('POST response: ');
// Should be 'OK' if everything was successful
console.log(text);
});
}
state = Object.assign(state, option.setState)
showTextNode(nextTextNodeId)
}