-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
57 lines (43 loc) · 1.63 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
from wsgiref import simple_server
from flask import Flask, request, app,render_template
from flask import Response
from flask_cors import CORS
import pickle
import bz2
import numpy as np
import pandas as pd
app = Flask(__name__)
CORS(app)
app.config['DEBUG'] = True
scalarobject=bz2.BZ2File("Model\standardScalar.pkl", "rb")
scaler=pickle.load(scalarobject)
modelforpred = bz2.BZ2File("Model\modelForPrediction.pkl", "rb")
model = pickle.load(modelforpred)
## 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")