-
Notifications
You must be signed in to change notification settings - Fork 40
/
app.py
33 lines (24 loc) · 865 Bytes
/
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
from flask import Flask, request, url_for, redirect, render_template
import pickle
import numpy as np
app = Flask(__name__, template_folder='./templates', static_folder='./static')
Pkl_Filename = "rf_tuned.pkl"
with open(Pkl_Filename, 'rb') as file:
model = pickle.load(file)
@app.route('/')
def hello_world():
return render_template('home.html')
@app.route('/predict', methods=['POST','GET'])
def predict():
features = [int(x) for x in request.form.values()]
print(features)
final = np.array(features).reshape((1,6))
print(final)
pred = model.predict(final)[0]
print(pred)
if pred < 0:
return render_template('op.html', pred='Error calculating Amount!')
else:
return render_template('op.html', pred='Expected amount is {0:.3f}'.format(pred))
if __name__ == '__main__':
app.run(debug=True)