-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
51 lines (38 loc) · 1.54 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,render_template
from src.pipeline.predict_pipeline import CustomData,PredictPipeline
from src.utils import scale
application=Flask(__name__)
app = application
#route for homepage
@app.route('/')
def home():
return render_template('home.html') #paragraph and tings from home
@app.route('/predict',methods=['GET', 'POST'])
def predict():
if request.method=='GET':
return render_template('home.html')
else:
data=CustomData(
policy_tenure=float(request.form.get('policy_tenure')),
age_of_car=float(request.form.get('age_of_car')),
age_of_policyholder=float(request.form.get('age_of_policyholder')),
population_density=float(request.form.get('population_density')),
steering_type=request.form.get('steering_type')
)
preds_df=data.get_data_as_dataframe()
#perform scaling
scale(preds_df,'policy_tenure',5,0.5) #for the policy tenure
scale(preds_df,'age_of_car',15,0) #for the vehicle age
scale(preds_df,'age_of_policyholder',52,18) #for age of the policyholder
print(preds_df)
predict_pipeline=PredictPipeline()
results=predict_pipeline.predict(preds_df)
return render_template('predicted.html', results=results[0])
@app.route("/Image/warning.png")
def warning():
return render_template("warning.png")
@app.route("/Image/okay.jpg")
def okay():
return render_template("okay.jpg")
if __name__=="__main__":
app.run(host="0.0.0.0")