Spaces:
Runtime error
Runtime error
File size: 1,249 Bytes
21e3bc3 7de57ad 21e3bc3 7de57ad |
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 |
import streamlit as st
import pandas as pd
import joblib
@st.cache_resource
def load_model():
data = joblib.load("model.pkl")
return data["model"], data["features"]
model, feature_names = load_model()
st.title("PROPERTY PRICE PREDICTION TOOL (Streamlit Version)")
st.markdown("Predict the price of a new property based on District, Longitude, Latitude, Floor, Unit, Area, Year, and Week Number.")
district = st.selectbox("District (1 = Taikoo Shing, 2 = Mei Foo Sun Chuen, 3 = South Horizons, 4 = Whampoa Garden)", list(range(1, 9)))
longitude = st.number_input("Longitude", value=114.200)
latitude = st.number_input("Latitude", value=22.300)
floor = st.selectbox("Floor", list(range(1, 71)))
unit = st.selectbox("Unit (e.g., A=1, B=2, C=3, ...)", list(range(1, 31)))
area = st.slider("Area (in sq. feet)", min_value=137, max_value=5000, value=300)
year = st.selectbox("Year", [2024, 2025])
weeknumber = st.selectbox("Week Number", list(range(1, 53)))
if st.button("Predict"):
new_data = [district, longitude, latitude, floor, unit, area, year, weeknumber]
df_new = pd.DataFrame([new_data], columns=feature_names)
prediction = model.predict(df_new)
st.success(f"๐ Estimated Price: **${prediction[0]:,.2f} Million**")
|