-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathml.py
More file actions
51 lines (37 loc) · 1.53 KB
/
ml.py
File metadata and controls
51 lines (37 loc) · 1.53 KB
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
import pandas as pd
import streamlit as st
import datetime
import pickle
cars_df = pd.read_excel("./cars24-car-price.xlsx")
st.write(
"""
# Cars24 Used Car Price Prediction
"""
)
st.dataframe(cars_df.head())
encode_dict = {
"fuel_type": {'Diesel': 1, 'Petrol': 2, 'CNG': 3, 'LPG': 4, 'Electric': 5},
"seller_type": {'Dealer': 1, 'Individual': 2, 'Trustmark Dealer': 3},
"transmission_type": {'Manual': 1, 'Automatic': 2}
}
def model_pred(fuel_type, transmission_type, engine, seats):
## loading the model
with open("car_pred", 'rb') as file:
reg_model = pickle.load(file)
input_features = [[2018.0, 1, 4000, fuel_type, transmission_type, 19.70, engine, 86.30, seats]]
return reg_model.predict(input_features)
## Formatting and adding dropdowns and sliders
col1, col2 = st.columns(2)
fuel_type = col1.selectbox("Select the fuel type",
["Diesel", "Petrol", "CNG", "LPG", "Electric"])
engine = col1.slider("Set the Engine Power",
500, 5000, step=100)
transmission_type = col2.selectbox("Select the transmission type",
["Manual", "Automatic"])
seats = col2.selectbox("Enter the number of seats",
[4,5,7,9,11])
if (st.button("Predict Price")):
fuel_type = encode_dict['fuel_type'][fuel_type]
transmission_type = encode_dict['transmission_type'][transmission_type]
price = model_pred(fuel_type, transmission_type, engine, seats)
st.text("Predicted Price of the car is: " + str(price))