omm7 commited on
Commit
cdace94
·
verified ·
1 Parent(s): b3c2466

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +17 -25
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 and preprocessor
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("Please enter the details below to get a prediction.")
20
-
21
- # Collect user input for numeric features with realistic ranges
22
- CRIM = st.number_input("Per capita crime rate by town (CRIM)", min_value=0.0, max_value=100.0, value=0.2, format="%.3f")
23
- ZN = st.number_input("Proportion of residential land zoned for lots over 25,000 sq.ft. (ZN)", min_value=0.0, max_value=100.0, value=12.0)
24
- INDUS = st.number_input("Proportion of non-retail business acres per town (INDUS)", min_value=0.0, max_value=30.0, value=11.0)
25
- NX = st.number_input("Nitric oxides concentration (parts per 10 million) (NX)", min_value=0.0, max_value=1.0, value=0.55, format="%.3f")
26
- RM = st.number_input("Average number of rooms per dwelling (RM)", min_value=3.0, max_value=9.0, value=6.3, format="%.2f")
27
- AGE = st.number_input("Proportion of owner-occupied units built prior to 1940 (AGE)", min_value=0.0, max_value=100.0, value=65.0)
28
- DIS = st.number_input("Weighted distances to employment centers (DIS)", min_value=1.0, max_value=12.0, value=4.0, format="%.3f")
29
- RAD = st.number_input("Index of accessibility to radial highways (RAD)", min_value=1, max_value=24, value=4)
30
- TAX = st.number_input("Full-value property tax rate per $10,000 (TAX)", min_value=100, max_value=700, value=300)
31
- PTRATIO = st.number_input("Pupil-teacher ratio by town (PTRATIO)", min_value=10.0, max_value=25.0, value=19.0, format="%.2f")
32
- LSTAT = st.number_input("% lower status of the population (LSTAT)", min_value=0.0, max_value=40.0, value=12.0, format="%.2f")
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.write(f"Estimated median value of owner-occupied home (MEDV): ${predicted_price*1000:,.2f}")
 
 
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}")