Question: There are 2 files main.py and us . py it is streamlit app that is used for predicting car price. I want you to style
There are files main.py and uspy it is streamlit app that is used for predicting car price. I want you to style the app like put some car photos when a car brand selected for example Audi, Citroen,DO IT FOR ALL CR BRANDS AND THEIR CORRESPONDING MODEL AS YOU CAN SEE IN THE CAR BRAND AND MODEL MAPS make some front end work maybe change background play with some front end styling style the streamlit app with best versionmake home page then convert current home to another page as prediction page do your maximum please.
import pandas as pd
import numpy as np
import streamlit as st
import folium
from folium import plugins
from sklearn.ensemble import RandomForestRegressor
from sklearn.modelselection import traintestsplit
from us import aboutus # Assuming this is the correct import for your about us module
# Read the normalized dataframe
dfnormalized pdreadcsvC:Usersseyfusalepredictioncsv
# Read the original dataframe
dforiginal pdreadcsvC:Usersseyfufinaldatacsv
# Map color names to numeric codes
colormap
'Altn:
'Bej':
'Beyaz':
'Bordo':
Dier:
Fme:
'Gri':
'Gri Gm:
'Gri metalik:
'Gri titanyum:
'Kahverengi':
Krmz:
'Lacivert':
'Mavi':
'Mavi metalik:
'Mor':
'Pembe':
'Sar:
'Siyah':
'Turkuaz':
'Turuncu':
Yeil:
Yeil metalik:
ampanya:
# Map brand names to numeric codes
brandmap
'Audi':
'Citroen':
'Fiat':
'Ford':
'Opel':
'Renault':
'Toyota':
'Volkswagen':
# Map model names to numeric codes
modelmap
:
:
A:
A:
A:
A:
A:
A:
A:
'Astra':
BX:
CElysee':
C:
C:
C:
C:
C:
C:
C:
'Clio':
'Corolla':
'Corsa':
'Egea':
'Evasion':
'Fiesta':
'Fluence':
'Focus':
'Golf':
'Linea':
'Polo':
S:
'Saxo':
TT:
'Xantia':
'Xsara':
ZX:
# Replace color, brand, and model numeric codes in the normalized dataframe
dfnormalizedColor dforiginalColormapcolormap
dfnormalizedCar Brand' dforiginalCar Brand'mapbrandmap
dfnormalizedModel dforiginalModelmapmodelmap
# Ensure that all features are properly encoded
X dfnormalized.dropPrice 'City', 'District' axis
y dfnormalizedPrice
# Split the dataset into training and testing sets
Xtrain, Xtest, ytrain, ytest traintestsplitX y testsize randomstate
# Train a RandomForestRegressor model
rf RandomForestRegressor
rffitXtrain, ytrain
# Streamlit app navigation
navigation stsidebar.radioNavigationHome "About Us
if navigation "Home":
stsidebar.headerUser Input Parameters'
# Add sliders, text inputs, or any other widgets for user input
year stsidebar.sliderSelect Car Year', minvalueXYearmin maxvalueXYearmax
valueintXYearmean
kilometers stsidebar.numberinputSelect Car Kilometers', minvalueXKilometersmin
maxvalueXKilometersmax valueintXKilometersmean
engine stsidebar.sliderSelect Engine Size', minvalueXEnginemin maxvalueXEnginemax
valueXEnginemean
color stsidebar.selectboxSelect Car Color', listcolormap.keys
brand stsidebar.selectboxSelect Car Brand', listbrandmap.keys
model stsidebar.selectboxSelect Car Model', listmodelmap.keys
# Define a predict button
predictbutton stsidebar.buttonPredict
if predictbutton:
# Retrieve the numeric code for the selected color, brand, and model
colornumeric colormapcolor
brandnumeric brandmapbrand
modelnumeric modelmapmodel
# Perform prediction
userinput year kilometers, engine, colornumeric, brandnumeric, modelnumeric
prediction rfpredictuserinput
# Display prediction result
stwrite## Car Price Prediction'
stwritefThe predicted price for the selected car is: TRY prediction:f
elif navigation "About Us:
aboutus # Call the aboutus function from the aboutus module
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
