forked from ialimustufa/ml-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (26 loc) · 890 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
from flask import Flask , render_template ,request
from flask_ngrok import run_with_ngrok
from sklearn.preprocessing import StandardScaler
import pickle
app = Flask(__name__)
run_with_ngrok(app)
model = pickle.load(open('model.pkl','rb'))
sc=StandardScaler()
@app.route('/')
def index():
return render_template('index.html',data="null")
@app.route('/predict',methods = ['GET','POST'])
def predict():
if request.method == 'POST':
gender = request.form['gender']
age= request.form['age']
sal= request.form['sal']
data=[[int(gender),int(age),int(sal)]]
p=model.predict(sc.fit_transform(data))
if p[0]==1:
prediction="User will purchase product"
else:
prediction="User won't purchase product"
return render_template('index.html',prediction="Prediction: "+prediction)
if __name__=='__main__':
app.run()