Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,35 +1,30 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
import joblib
|
| 5 |
|
| 6 |
-
# Load the trained regression model
|
| 7 |
def load_model():
|
| 8 |
return joblib.load("boston_housing_model_v1_0.joblib")
|
| 9 |
|
| 10 |
-
# def load_preprocessor():
|
| 11 |
-
# return joblib.load("preprocessor_v1_0.joblib")
|
| 12 |
-
|
| 13 |
model = load_model()
|
| 14 |
-
# preprocessor = load_preprocessor()
|
| 15 |
|
| 16 |
# Streamlit UI for Boston Housing Price Prediction
|
| 17 |
-
st.title("Boston Housing Price Prediction App")
|
| 18 |
st.write("This app predicts the median value of owner-occupied homes (`MEDV`) in $1000s based on Boston housing dataset features.")
|
| 19 |
-
st.write("
|
| 20 |
-
|
| 21 |
-
# Collect user input
|
| 22 |
-
CRIM = st.
|
| 23 |
-
ZN = st.
|
| 24 |
-
INDUS = st.
|
| 25 |
-
NX = st.
|
| 26 |
-
RM = st.
|
| 27 |
-
AGE = st.
|
| 28 |
-
DIS = st.
|
| 29 |
-
RAD = st.
|
| 30 |
-
TAX = st.
|
| 31 |
-
PTRATIO = st.
|
| 32 |
-
LSTAT = st.
|
| 33 |
|
| 34 |
# Categorical feature
|
| 35 |
CHAS = st.selectbox("Charles River dummy variable (CHAS)", ["0 (No)", "1 (Yes)"])
|
|
@@ -51,10 +46,7 @@ input_data = pd.DataFrame([{
|
|
| 51 |
'CHAS': CHAS_value
|
| 52 |
}])
|
| 53 |
|
| 54 |
-
# Apply preprocessing
|
| 55 |
-
# input_data_preprocessed = preprocessor.transform(input_data)
|
| 56 |
-
|
| 57 |
# Predict button
|
| 58 |
if st.button("Predict MEDV"):
|
| 59 |
predicted_price = model.predict(input_data)[0]
|
| 60 |
-
st.
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import joblib
|
| 4 |
|
| 5 |
+
# Load the trained regression model
|
| 6 |
def load_model():
|
| 7 |
return joblib.load("boston_housing_model_v1_0.joblib")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
model = load_model()
|
|
|
|
| 10 |
|
| 11 |
# Streamlit UI for Boston Housing Price Prediction
|
| 12 |
+
st.title("🏠 Boston Housing Price Prediction App")
|
| 13 |
st.write("This app predicts the median value of owner-occupied homes (`MEDV`) in $1000s based on Boston housing dataset features.")
|
| 14 |
+
st.write("Move the sliders below to adjust values and get a prediction.")
|
| 15 |
+
|
| 16 |
+
# Collect user input using sliders
|
| 17 |
+
CRIM = st.slider("Per capita crime rate by town (CRIM)", 0.0, 100.0, 0.2, 0.1)
|
| 18 |
+
ZN = st.slider("Proportion of residential land zoned for lots over 25,000 sq.ft. (ZN)", 0.0, 100.0, 12.0, 1.0)
|
| 19 |
+
INDUS = st.slider("Proportion of non-retail business acres per town (INDUS)", 0.0, 30.0, 11.0, 0.5)
|
| 20 |
+
NX = st.slider("Nitric oxides concentration (NX)", 0.0, 1.0, 0.55, 0.01)
|
| 21 |
+
RM = st.slider("Average number of rooms per dwelling (RM)", 3.0, 9.0, 6.3, 0.1)
|
| 22 |
+
AGE = st.slider("Proportion of owner-occupied units built prior to 1940 (AGE)", 0.0, 100.0, 65.0, 1.0)
|
| 23 |
+
DIS = st.slider("Weighted distances to employment centers (DIS)", 1.0, 12.0, 4.0, 0.1)
|
| 24 |
+
RAD = st.slider("Index of accessibility to radial highways (RAD)", 1, 24, 4, 1)
|
| 25 |
+
TAX = st.slider("Full-value property tax rate per $10,000 (TAX)", 100, 700, 300, 1)
|
| 26 |
+
PTRATIO = st.slider("Pupil-teacher ratio by town (PTRATIO)", 10.0, 25.0, 19.0, 0.1)
|
| 27 |
+
LSTAT = st.slider("% lower status of the population (LSTAT)", 0.0, 40.0, 12.0, 0.1)
|
| 28 |
|
| 29 |
# Categorical feature
|
| 30 |
CHAS = st.selectbox("Charles River dummy variable (CHAS)", ["0 (No)", "1 (Yes)"])
|
|
|
|
| 46 |
'CHAS': CHAS_value
|
| 47 |
}])
|
| 48 |
|
|
|
|
|
|
|
|
|
|
| 49 |
# Predict button
|
| 50 |
if st.button("Predict MEDV"):
|
| 51 |
predicted_price = model.predict(input_data)[0]
|
| 52 |
+
st.success(f"💰 Estimated Median Value of Home (MEDV): ${predicted_price*1000:,.2f}")
|