-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
53 lines (41 loc) · 1.52 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
52
53
from flask import Flask,request,render_template
import numpy as np
import pandas as pd
from src.pipeline.predict_pipeline import CustomData,PredictPipeline
application=Flask(__name__)
app=application
## Route for a home page
# Remove Random addition
@app.route('/')
def index():
return render_template('index.html')
@app.route('/predictdata',methods=['GET','POST'])
def predict_datapoint():
if request.method=='GET':
return render_template('home.html')
else:
data=CustomData(
Pregnancies=int(request.form.get('Pregnancies')),
Glucose=int(request.form.get('Glucose')),
BloodPressure=int(request.form.get('BloodPressure')),
SkinThickness=int(request.form.get('SkinThickness')),
Insulin=int(request.form.get('Insulin')),
BMI=float(request.form.get('BMI')),
DiabetesPedigreeFunction=float(request.form.get('DiabetesPedigreeFunction')),
Age=int(request.form.get('Age'))
)
pred_df=data.get_data_as_data_frame()
print(pred_df)
print("Before Prediction")
predict_pipeline=PredictPipeline()
print("Mid Prediction")
pred=predict_pipeline.predict(pred_df)
print('This is the prediction: ', pred)
if pred == 1:
results = 'Diabetic'
else:
results = 'Non-Diabetic'
print("after Prediction")
return render_template('home.html',results=results)
if __name__=="__main__":
app.run(host="0.0.0.0",port=5000)