-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
30 lines (25 loc) · 1.08 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
from flask import Flask,render_template,request
import pandas as pd
import numpy as np
import pickle
app = Flask(__name__)
model = pickle.load(open("LinearRegressionModel.pkl","rb"))
car = pd.read_csv('cleaned car.csv')
@app.route('/')
def index():
companies = sorted(car['company'].unique())
car_models = sorted(car['name'].unique())
year = sorted(car['year'].unique(), reverse=True)
fuel_type = car['fuel_type'].unique()
return render_template('index.html',companies = companies,car_models=car_models,years = year,fuel_type = fuel_type)
@app.route('/predict',methods=['POST'])
def predict():
company = request.form.get('company')
car_model = request.form.get('car_models')
year = request.form.get('year')
fuel = request.form.get('fuel_type')
kms_driven = request.form.get('kms_driven')
prediction = model.predict(pd.DataFrame([[car_model,company,year,kms_driven,fuel]],columns=['name','company','year','kms_driven','fuel_type']))
return str(np.round(prediction[0],2))
if __name__ == '__main__':
app.run(debug=True)