-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
56 lines (40 loc) · 1.41 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
51
52
53
54
55
56
from flask import Flask, request, render_template
import os
import pickle
print(os.getcwd())
path = os.getcwd()
with open('Models/svm_heart.pkl', 'rb') as f:
svm_model = pickle.load(f)
def get_predictions(age,sex,cp,trestbps,chol,fbs,restecg,thalach,exang,oldpeak,slope,ca, thal, req_model):
mylist = [age,sex,cp,trestbps,chol,fbs,restecg,thalach,exang,oldpeak,slope,ca, thal]
mylist = [float(i) for i in mylist]
vals = [mylist]
if req_model == 'SVM':
#print(req_model)
return svm_model.predict(vals)[0]
else:
return "Cannot Predict"
app = Flask(__name__)
@app.route('/')
def my_form():
return render_template('home.html')
@app.route('/', methods=['POST', 'GET'])
def my_form_post():
age = request.form['age']
sex = request.form['sex']
cp = request.form['cp']
trestbps = request.form['trestbps']
chol = request.form['chol']
fbs = request.form['fbs']
restecg = request.form['restecg']
thalach = request.form['thalach']
exang = request.form['exang']
oldpeak = request.form['oldpeak']
slope = request.form['slope']
ca = request.form['ca']
thal = request.form['thal']
req_model = request.form['req_model']
target = get_predictions(age,sex,cp,trestbps,chol,fbs,restecg,thalach,exang,oldpeak,slope,ca, thal, req_model)
return render_template('home.html', target = target)
if __name__ == "__main__":
app.run(debug=True)