-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
50 lines (43 loc) · 2.02 KB
/
app.py
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
import numpy as np
from flask import Flask,request,jsonify,render_template
import pickle
app = Flask(__name__)
model = pickle.load(open("regmodel.pkl", "rb"))
@app.route('/')
def html_page():
return render_template('home.html')
@app.route('/submit', methods=['POST','GET'])
def products():
return render_template('result.html', pred = predict())
def predict():
# my_dictionary = {'Artist':0,'Banker':1,'Business Owner':2,'Construction Engineer':3, 'Designer':4,'Doctor':5, 'Game Developer':6,
# 'Government Officer':7, 'Lawyer':8,'Real Estate Developer':9,'Scientist':10, 'Software Engineer':11,'Stock Investor':12,
# 'Teacher':13,'Unknown':14, 'Writer':15}
float_features = []
for x in request.form.values() :
float_features.append(float(x))
# if(x=='female'):
# float_features.append(1.0)
# elif(x=='do'):
# float_features.append(1.0)
# elif(x=='donot do'):
# float_features.append(0.0)
# elif(x=='involve'):
# float_features.append(1.0)
# elif(x=='not involve'):
# float_features.append(0.0)
# elif(x=='Artist' or x=='Banker' or x=='Business Owner' or x=='Construction Engineer' or x=='Designer' or x=='Doctor' or x=='Game Developer'or x==
# 'Government Officer'or x=='Lawyer'or x=='Real Estate Developer' or x=='Scientist'or x== 'Software Engineer'or x=='Stock Investor'or x==
# 'Teacher'or x=='Unknown'or x=='Writer') :
# for i in range(16):
# if(i==my_dictionary[x]):
# float_features.append(1.0)
# else:
# float_features.append(0.0)
# elif 0 <= int(x) <= 100:
# float_features.append(float(x))
features = [np.array(float_features)]
prediction = model.predict(features)
return prediction
#if __name__== "__main__":
# app.run(debug=True)