YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
import streamlit as st import pandas as pd import joblib
Load Model
model = joblib.load("LR_BMW.pkl") scaler = joblib.load("scaler.pkl") columns = joblib.load("columns.pkl")
st.set_page_config( page_title="BMW Car Price Prediction", page_icon="๐", layout="centered" )
st.title("๐ BMW Car Price Prediction")
st.markdown("Enter Car Details")
Inputs
year = st.number_input("Year", 1990, 2035, 2018)
mileage = st.number_input("Mileage", 0, 300000, 30000)
tax = st.number_input("Tax", 0, 1000, 150)
mpg = st.number_input("MPG", 0.0, 150.0, 55.4)
engineSize = st.number_input("Engine Size", 0.5, 8.0, 2.0)
model_name = st.selectbox( "Select BMW Model", [ "1 Series", "2 Series", "3 Series", "4 Series", "5 Series", "6 Series", "7 Series", "8 Series", "X1", "X2", "X3", "X4", "X5", "X6", "X7", "Z3", "Z4", "M2", "M3", "M4", "M5", "M6", "i3", "i8" ] )
transmission = st.selectbox( "Transmission", ["Manual", "Automatic", "Semi-Auto"] )
fuelType = st.selectbox( "Fuel Type", ["Petrol", "Diesel", "Hybrid", "Electric"] )
Prediction
if st.button("Predict Price"):
input_df = pd.DataFrame([{
"year": year,
"mileage": mileage,
"tax": tax,
"mpg": mpg,
"engineSize": engineSize,
"model": model_name,
"transmission": transmission,
"fuelType": fuelType
}])
input_df = pd.get_dummies(input_df, drop_first=True)
input_df = input_df.reindex(columns=columns, fill_value=0)
input_scaled = scaler.transform(input_df)
prediction = model.predict(input_scaled)
st.success(f"Estimated Price: ยฃ {prediction[0]:,.2f}")