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 2 files main.py and us.py 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.model_selection import train_test_split
from us import about_us # Assuming this is the correct import for your about us module
# Read the normalized dataframe
df_normalized = pd.read_csv('C:\\Users\\seyfu\\sale_prediction2.csv')
# Read the original dataframe
df_original = pd.read_csv('C:\\Users\\seyfu\\final_data3.csv')
# Map color names to numeric codes
color_map ={
'Altn': 0,
'Bej': 1,
'Beyaz': 2,
'Bordo': 3,
'Dier': 4,
'Fme': 5,
'Gri': 6,
'Gri (Gm)': 7,
'Gri (metalik)': 8,
'Gri (titanyum)': 9,
'Kahverengi': 10,
'Krmz': 11,
'Lacivert': 12,
'Mavi': 13,
'Mavi (metalik)': 14,
'Mor': 15,
'Pembe': 16,
'Sar': 17,
'Siyah': 18,
'Turkuaz': 19,
'Turuncu': 20,
'Yeil': 21,
'Yeil (metalik)': 22,
'ampanya': 23
}
# Map brand names to numeric codes
brand_map ={
'Audi': 0,
'Citroen': 1,
'Fiat': 2,
'Ford': 3,
'Opel': 4,
'Renault': 5,
'Toyota': 6,
'Volkswagen': 7
}
# Map model names to numeric codes
model_map ={
'100': 0,
'80': 1,
'A1': 2,
'A3': 3,
'A4': 4,
'A5': 5,
'A6': 6,
'A7': 7,
'A8': 8,
'Astra': 9,
'BX': 10,
'C-Elysee': 11,
'C1': 12,
'C2': 13,
'C3': 14,
'C4': 15,
'C5': 16,
'C6': 17,
'C8': 18,
'Clio': 19,
'Corolla': 20,
'Corsa': 21,
'Egea': 22,
'Evasion': 23,
'Fiesta': 24,
'Fluence': 25,
'Focus': 26,
'Golf': 27,
'Linea': 28,
'Polo': 29,
'S': 30,
'Saxo': 31,
'TT': 32,
'Xantia': 33,
'Xsara': 34,
'ZX': 35
}
# Replace color, brand, and model numeric codes in the normalized dataframe
df_normalized['Color']= df_original['Color'].map(color_map)
df_normalized['Car Brand']= df_original['Car Brand'].map(brand_map)
df_normalized['Model']= df_original['Model'].map(model_map)
# Ensure that all features are properly encoded
X = df_normalized.drop(['Price', 'City', 'District'], axis=1)
y = df_normalized['Price']
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=100)
# Train a RandomForestRegressor model
rf = RandomForestRegressor()
rf.fit(X_train, y_train)
# Streamlit app navigation
navigation = st.sidebar.radio("Navigation",["Home", "About Us"])
if navigation == "Home":
st.sidebar.header('User Input Parameters')
# Add sliders, text inputs, or any other widgets for user input
year = st.sidebar.slider('Select Car Year', min_value=X['Year'].min(), max_value=X['Year'].max(),
value=int(X['Year'].mean()))
kilometers = st.sidebar.number_input('Select Car Kilometers', min_value=X['Kilometers'].min(),
max_value=X['Kilometers'].max(), value=int(X['Kilometers'].mean()))
engine = st.sidebar.slider('Select Engine Size', min_value=X['Engine'].min(), max_value=X['Engine'].max(),
value=X['Engine'].mean())
color = st.sidebar.selectbox('Select Car Color', list(color_map.keys()))
brand = st.sidebar.selectbox('Select Car Brand', list(brand_map.keys()))
model = st.sidebar.selectbox('Select Car Model', list(model_map.keys()))
# Define a predict button
predict_button = st.sidebar.button('Predict')
if predict_button:
# Retrieve the numeric code for the selected color, brand, and model
color_numeric = color_map[color]
brand_numeric = brand_map[brand]
model_numeric = model_map[model]
# Perform prediction
user_input =[[year, kilometers, engine, color_numeric, brand_numeric, model_numeric]]
prediction = rf.predict(user_input)
# Display prediction result
st.write('## Car Price Prediction')
st.write(f'The predicted price for the selected car is: TRY {prediction[0]:.2f}')
elif navigation == "About Us":
about_us() # Call the about_us function from the about_us module

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!