-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
41 lines (31 loc) · 1.18 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
from flask import Flask, request, url_for, redirect, render_template
import pickle
import pandas as pd
app = Flask(__name__)
model = pickle.load(open("Diabetes.pkl", "rb"))
@app.route('/')
def hello_world():
return render_template("try.html")
@app.route('/predict', methods=['POST', 'GET'])
def predict():
text1 = request.form['1']
text2 = request.form['2']
text3 = request.form['3']
text4 = request.form['4']
text5 = request.form['5']
text6 = request.form['6']
text7 = request.form['7']
text8 = request.form['8']
row_df = pd.DataFrame(
[pd.Series([text1, text2, text3, text4, text5, text6, text7, text8])])
print(row_df)
prediction = model.predict_proba(row_df)
output = round(prediction[0][1]*100, 2)
output = str(output)+'%'
print(output)
if output > str(1):
return render_template('result.html', pred=['You have chance of having diabetes. ', f' Probability of having Diabetes is {output}'])
else:
return render_template('result.html', pred=['You are safe. ', f' Probability of having Diabetes is {output}'])
if __name__ == '__main__':
app.run(debug=True)