Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +31 -0
- elite27.pkl +3 -0
- requirements.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# β
Load the trained model in binary mode ('rb')
|
| 6 |
+
model_path = r"C:/Users/DELL/Downloads/3746233-Week_1/elite27.pkl"
|
| 7 |
+
|
| 8 |
+
try:
|
| 9 |
+
with open(model_path, "rb") as f:
|
| 10 |
+
model = pickle.load(f)
|
| 11 |
+
st.success("β
Model loaded successfully!")
|
| 12 |
+
except Exception as e:
|
| 13 |
+
st.error(f"β Error loading model: {e}")
|
| 14 |
+
st.stop() # Stop execution if model can't be loaded
|
| 15 |
+
|
| 16 |
+
# β
Input fields
|
| 17 |
+
st.title("π‘ House Price Prediction App")
|
| 18 |
+
square_feet = st.number_input("Enter Square Feet:", min_value=500, max_value=10000)
|
| 19 |
+
bedrooms = st.number_input("Enter Number of Bedrooms:", min_value=1, max_value=10)
|
| 20 |
+
bathrooms = st.number_input("Enter Number of Bathrooms:", min_value=1, max_value=10)
|
| 21 |
+
neighborhood = st.selectbox("Select Neighborhood", [0, 1, 2], format_func=lambda x: ["Rural", "Semi Urban", "Urban"][x])
|
| 22 |
+
year_built = st.number_input("Enter Year Built:", min_value=1900, max_value=2025)
|
| 23 |
+
|
| 24 |
+
# β
Predict price
|
| 25 |
+
if st.button("Predict Price π°"):
|
| 26 |
+
try:
|
| 27 |
+
user_data = np.array([[square_feet, bedrooms, bathrooms, neighborhood, year_built]], dtype=float)
|
| 28 |
+
prediction = model.predict(user_data)
|
| 29 |
+
st.success(f"π Estimated House Price: ${prediction[0]:,.2f}")
|
| 30 |
+
except Exception as e:
|
| 31 |
+
st.error(f"β Prediction error: {e}")
|
elite27.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:895e1c0f50832213cac2303d43b8da918cd412d82a52aa5b98b96c570531146f
|
| 3 |
+
size 633
|
requirements.txt
ADDED
|
File without changes
|