-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
51 lines (37 loc) · 1.47 KB
/
application.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
from flask import Flask, request, app,render_template
from flask import Response
import pickle
import numpy as np
import pandas as pd
application = Flask(__name__)
app=application
scaler=pickle.load(open("models/scaler.pkl", "rb"))
model = pickle.load(open("models/ModelForPrediction.pkl", "rb"))
## Route for homepage
@app.route('/')
def index():
return render_template('index.html')
## Route for Single data point prediction
@app.route('/predictdata',methods=['GET','POST'])
def predict_datapoint():
result=""
if request.method=='POST':
Pregnancies=int(request.form.get("Pregnancies"))
Glucose = float(request.form.get('Glucose'))
BloodPressure = float(request.form.get('BloodPressure'))
SkinThickness = float(request.form.get('SkinThickness'))
Insulin = float(request.form.get('Insulin'))
BMI = float(request.form.get('BMI'))
DiabetesPedigreeFunction = float(request.form.get('DiabetesPedigreeFunction'))
Age = float(request.form.get('Age'))
new_data=scaler.transform([[Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age]])
predict=model.predict(new_data)
if predict[0] ==1 :
result = 'Diabetic'
else:
result ='Non-Diabetic'
return render_template('single_prediction.html',result=result)
else:
return render_template('home.html')
if __name__=="__main__":
app.run(host="0.0.0.0")