-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
69 lines (55 loc) · 2.5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
from flask import Flask, render_template, request, jsonify
import pickle
import numpy as np
app=Flask(__name__)
# instantiate object
#loading the different saved model for different disease
diabetes_predict=pickle.load(open('diabetes.pkl', 'rb'))
heart_predict=pickle.load(open('heart.pkl', 'rb'))
parkinsons_predict=pickle.load(open('parkinsons.pkl', 'rb'))
@app.route('/') # instancing one page (homepage)
def home():
return render_template("home.html")
# ^^ open home.html, then see that it extends layout.
# render home page.
@app.route('/diabetes') # instancing child page
def diabetes():
return render_template("diabetes.html")
@app.route('/parkinsons/') # instancing child page
def parkinsons():
return render_template("parkinsons.html")
@app.route('/heartdisease/') # instancing child page
def heartdisease():
return render_template("heartdisease.html")
@app.route('/predictdiabetes/',methods=['POST'])
def predictdiabetes(): #function to predict diabetes
int_features=[x for x in request.form.values()]
processed_feature_diabetes=[np.array(int_features,dtype=float)]
prediction=diabetes_predict.predict(processed_feature_diabetes)
if prediction[0]==1:
display_text="This person has Diabetes"
else:
display_text="This person doesn't have Diabetes"
return render_template('diabetes.html',output_text="Result: {}".format(display_text))
@app.route('/predictparkinson/',methods=['POST'])
def predictparkinsons(): #function to predict parkinsons disease
int_features=[x for x in request.form.values()]
processed_feature_parkinsons=[np.array(int_features,dtype=float)]
prediction=parkinsons_predict.predict(processed_feature_parkinsons)
if prediction[0]==1:
display_text="This person has Parkinson's"
else:
display_text="This person doesn't have Parkinson's"
return render_template('parkinsons.html',output_text="Result: {}".format(display_text))
@app.route('/predictheartdisease/',methods=['POST'])
def predictheartdisease(): #function to predict heart disease
int_features=[x for x in request.form.values()]
processed_feature_heart=[np.array(int_features,dtype=float)]
prediction=heart_predict.predict(processed_feature_heart)
if prediction[0]==1:
display_text="This person has Heart Disease"
else:
display_text="This person doesn't have Heart Disease"
return render_template('heartdisease.html',output_text="Result: {}".format(display_text))
if __name__=="__main__":
app.run(debug=True)