-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
53 lines (40 loc) · 1.68 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
from flask import Flask,request,render_template
from src.pipeline.prediction_pipeline import CustomData,PredictPipeline
application=Flask(__name__)
app=application
@app.route('/')
def home_page():
return render_template('index.html')
@app.route('/predict',methods=['GET','POST'])
def predict_datapoint():
if request.method=='GET':
return render_template('form.html')
else:
data = CustomData(
age=float(request.form.get('age')),
education_num = float(request.form.get('education_num')),
capital_gain = float(request.form.get('capital_gain')),
hours_per_week = float(request.form.get('hours_per_week')),
workclass = request.form.get('workclass'),
education= request.form.get('education'),
marital_status = request.form.get('marital_status'),
occupation = request.form.get('occupation'),
relationship = request.form.get('relationship'),
race = request.form.get('race'),
sex = request.form.get('sex'),
native_country = request.form.get('native_country'),
fnlwgt = float(request.form.get('fnlwgt')),
capital_loss = float(request.form.get('capital_loss'))
)
final_new_data=data.get_data_as_dataframe()
predict_pipeline=PredictPipeline()
pred=predict_pipeline.predict(final_new_data)
result = pred[0]
output = ""
if result == 0:
output = "Less than 50K"
else:
output = "More than 50K"
return render_template('results.html',final_result=output)
if __name__=="__main__":
app.run(host='0.0.0.0',debug=True,port=5000)