-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
52 lines (39 loc) · 1.39 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
import pickle
from flask import Flask, render_template, request
import numpy as np
app = Flask(__name__)
# load the model
filename = r'model/heart_disease.pkl'
model = pickle.load(open(filename, 'rb'))
# load the scaler
scaler_filename = r'model/scaler.pkl'
scaler = pickle.load(open(scaler_filename, 'rb'))
@app.route("/")
def home():
return render_template('/index.html')
@app.route("/result", methods=["POST"])
def submit():
age = int(request.form['age'])
sex = int(request.form['sex'] == "male")
cp = int(request.form['cp'])
trtbps = int(request.form['trtbps'])
chol = int(request.form['chol'])
restecg = int(request.form['restecg'])
thalachh = int(request.form['thalachh'])
exng = int(request.form['exng'])
oldpeak = float(request.form['oldpeak'])
slp = int(request.form['slp'])
caa = int(request.form['caa'])
thall = int(request.form['thall'])
o2Saturation = float(request.form['o2Saturation'])
data = np.array([age,sex,cp,trtbps,chol,restecg,thalachh,exng,oldpeak,slp,caa,thall,o2Saturation])
data = data.reshape(1, -1)
data = scaler.transform(data)
output = model.predict(data)
print(output)
if output == 0:
return render_template("/result.html", result="Not Risky")
else:
return render_template("/result.html", result="Risky")
if __name__ == '__main__':
app.run(debug=True,user_reloader=True)