-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
45 lines (33 loc) · 1.24 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
from flask import Flask, request, render_template
import pickle
app = Flask(__name__) # initialising flask app
model = pickle.load(open('model', 'rb')) # load ml model
@app.route('/', methods=['GET'])
def home():
return render_template('index.html')
@app.route('/', methods=['POST', 'GET'])
def predict():
if request.method == 'POST':
present_price = float(request.form['price'])
car_age = int(request.form['age'])
seller_type = request.form['seller']
fuel_type = request.form['fuel']
transmission_type = request.form['transmission']
if fuel_type == 'Diesel':
fuel_type = 1
else:
fuel_type = 0
if seller_type == 'Individual':
seller_type = 1
else:
seller_type = 0
if transmission_type == 'Manual':
transmission_type = 1
else:
transmission_type = 0
#model = pickle.load(open('model', 'rb')) # load ml model
prediction = model.predict([[present_price, car_age, fuel_type, seller_type, transmission_type]])
output = round(prediction[0], 2)
return render_template('index.html', output="{} $".format(output))
if __name__ == '__main__':
app.run(debug=True)