-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebApp.py
142 lines (116 loc) · 4.47 KB
/
webApp.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import streamlit as st
import pickle
from datetime import date
# from joblib import load
# Loading the model
model = pickle.load(open('Car_Predictor.pkl', 'rb'))
# model = load('Car_Predict.joblib')
def pageLoadup():
# Basic details about the page
title = "Car Price Predictor"
st.set_page_config(page_title=title, page_icon="🏎️")
st.title("🏎️ Car Price Predictor 🏎️", anchor=None)
st.subheader("Are you planning to sell you car ?", anchor=None)
st.subheader("Use me to know your best worth!!!", anchor=None)
st.image("./assets/image.png")
st.write('')
st.write('')
# Hiding the Streamlit header and footer
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
footer:after {
content:'© Adarsh-619';
visibility: visible;
display: block;
text-align: center;
font-size: 20px;
position: relative;
color: white;
padding: 10px;
top: 2px;
}
button[title="View fullscreen"] {visibility: hidden;}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)
def stylingComponents():
# div.stAlert {
# background-color: #72CC50;
# border: 1px solid black;
# opacity: 0.3;
# }
btn_st = """
<style>
#car-price-predictor{
text-align: center;
color: white;
}
#are-you-planning-to-sell-you-car, #use-me-to-know-your-best-worth{
color: white;
}
.stApp{
background-color: #282C34;
}
.stButton > button{
background-color: #61AFEF;
color: white;
font-size: 25px;
margin-left: 35%;
margin-top: 3%;
}
.stNumberInput > label, .stRadio > label, .stSelectbox > label {
font-size: 20px;
color: white;
}
.st-d1 {
font-size: 20px;
color: black;
}
div.stAlert p {
font-weight: bold;
color: #FFE77AFF;
}
</style>
"""
st.markdown(btn_st, unsafe_allow_html=True)
def inputData():
Years = st.number_input("In which year the car was purchased?", 1990, date.today().year, step=1, key='year')
Present_Price = st.number_input('What is the current ex-showroom price of the car ? (In ₹lakhs)', 0.00, 50.00, step=0.5, key ='present_price')
Kms_Driven = st.number_input("What is the distance completed by the car in Kilometers?", )
Owner = st.radio("The number of owners the car previously had? ", (0, 1, 2), key="owner")
Fuel_Type = st.selectbox("What is the fuel type of the car? ", ("Petrol", "Diesel", "CNG"), key='fuel_type')
if(Fuel_Type == "Petrol"):
Fuel_Type = 0
elif(Fuel_Type == "Diesel"):
Fuel_Type = 1
else:
Fuel_Type = 2
Seller_Type = st.selectbox("What is the Seller type of the car? ", ("Dealer", "Individual"), key='seller_type')
if(Seller_Type == "Dealer"):
Seller_Type = 0
else:
Seller_Type = 1
Transmission = st.selectbox("What is the Transmission Type of the car? ", ("Manual", "Automatic"), key="transmission")
if (Transmission == "Manual"):
Transmission = 0
else:
Transmission = 1
if(st.button("Estimate Price", key="predict")):
try:
prediction = model.predict([[Years, Present_Price, Kms_Driven, Fuel_Type, Seller_Type, Transmission, Owner]])
output = round(prediction[0], 2)
if output < 0:
st.warning("Sorry! You won't be able to sell this car...")
else:
st.success(f"You can sell this car for ₹{str(output)} Lakhs 🙌")
except:
st.warning("Oops🙄 Something went wrong\nPlease Try Again")
def main():
pageLoadup()
stylingComponents()
inputData()
if __name__ == "__main__":
main()