Spaces:
Sleeping
Sleeping
File size: 1,827 Bytes
557cb02 323718e 557cb02 323718e 557cb02 323718e 557cb02 323718e 557cb02 323718e 557cb02 323718e 557cb02 323718e 557cb02 323718e 557cb02 323718e | 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 | import streamlit as st
import pandas as pd
import joblib
import os
# ======================
# LOAD MODEL
# ======================
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
model = joblib.load(os.path.join(BASE_DIR, "house_price_model.pkl"))
# ======================
# PAGE CONFIG
# ======================
st.set_page_config(
page_title="House Price Prediction",
page_icon="🏡",
layout="centered"
)
st.title("🏡 House Price Prediction")
st.write("Predict the house price based on key features")
# ======================
# SIDEBAR INPUTS
# ======================
st.sidebar.header("House Features")
OverallQual = st.sidebar.slider("Overall Quality", 1, 10, 5)
GrLivArea = st.sidebar.number_input("Above Ground Living Area (sq ft)", 300, 5000, 1500)
GarageCars = st.sidebar.slider("Garage Capacity (cars)", 0, 4, 2)
TotalBsmtSF = st.sidebar.number_input("Total Basement Area (sq ft)", 0, 3000, 800)
FullBath = st.sidebar.slider("Full Bathrooms", 0, 4, 2)
YearBuilt = st.sidebar.slider("Year Built", 1900, 2024, 2000)
Neighborhood = st.sidebar.selectbox(
"Neighborhood",
[
"NAmes", "CollgCr", "OldTown", "Edwards", "Somerst",
"Gilbert", "NridgHt", "Sawyer", "NWAmes", "SawyerW"
]
)
# ======================
# DATAFRAME
# ======================
input_df = pd.DataFrame({
"OverallQual": [OverallQual],
"GrLivArea": [GrLivArea],
"GarageCars": [GarageCars],
"TotalBsmtSF": [TotalBsmtSF],
"FullBath": [FullBath],
"YearBuilt": [YearBuilt],
"Neighborhood": [Neighborhood]
})
st.subheader("Input Data")
st.write(input_df)
# ======================
# PREDICTION
# ======================
if st.button("Predict Price"):
prediction = model.predict(input_df)[0]
st.subheader("Estimated House Price 💰")
st.success(f"${prediction:,.0f}") |