/
working-se.py
68 lines (43 loc) · 1.36 KB
/
working-se.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
57
58
59
60
61
62
63
64
65
66
67
from flask import Flask, request, render_template
import numpy as np
import pickle
app = Flask(__name__)
@app.route('/')
def my_form():
return render_template('form.html')
@app.route('/', methods=['POST'])
def my_form_post():
#temperature = request.form['temperature']
a = request.form['temperature']
b = request.form['thal']
c = request.form['resting_blood_pressure']
d = request.form['chest_pain_type']
e = request.form['num_major_vessels']
f = request.form['fasting_blood_sugar']
g = request.form['resting_ekg_results']
h = request.form['serum_cholesterol']
i = request.form['oldpeak_eq_st_depression']
j = request.form['sex']
k = request.form['age']
l = request.form['max_heart_rate_achieved']
m = request.form['exercise_induced_angina']
testData = np.array([a,b,c,d,e,f,g,h,i,j,k,l,m]).reshape(1,13)
class_prediced = int(heartModel.predict(testData)[0])
output = "Predicted Class: " + str(class_prediced)
if class_prediced==0:
output = "Patient has no heart disease"
return (output)
elif class_prediced ==1:
output = "Patient has heart disease"
return (output)
return "error"
def load_model():
global heartModel
heartFile = open('models/model.pckl', 'rb')
heartModel = pickle.load(heartFile)
heartFile.close()
if __name__ == "__main__":
print("**Starting Server...")
load_model()
# Run Server
app.run()