riverosS commited on
Commit
e923a43
·
verified ·
1 Parent(s): 3522b66

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +9 -15
  2. app.py +52 -0
  3. boston_housing_model_v1_0.joblib +3 -0
  4. requirements.txt +6 -3
Dockerfile CHANGED
@@ -1,20 +1,14 @@
1
- FROM python:3.13.5-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
10
 
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
14
- RUN pip3 install -r requirements.txt
15
-
16
- EXPOSE 8501
17
-
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
-
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Use a minimal base image with Python 3.9 installed
2
+ FROM python:3.9-slim
3
 
4
+ # Set the working directory inside the container to /app
5
  WORKDIR /app
6
 
7
+ # Copy all files from the current directory on the host to the container's /app directory
8
+ COPY . .
 
 
 
9
 
10
+ # Install Python dependencies listed in requirements.txt
11
+ RUN pip3 install --no-cache-dir -r requirements.txt
12
 
13
+ # Define the command to run the Streamlit app on port 8501 and make it accessible externally
14
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)"])
31
+ CHAS_value = 1 if CHAS.startswith("1") else 0
32
+
33
+ # Create input DataFrame
34
+ input_data = pd.DataFrame([{
35
+ 'CRIM': CRIM,
36
+ 'ZN': ZN,
37
+ 'INDUS': INDUS,
38
+ 'NX': NX,
39
+ 'RM': RM,
40
+ 'AGE': AGE,
41
+ 'DIS': DIS,
42
+ 'RAD': RAD,
43
+ 'TAX': TAX,
44
+ 'PTRATIO': PTRATIO,
45
+ 'LSTAT': LSTAT,
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}")
boston_housing_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f49f57a85f57e4ffd4861e9d01a904c6508563fc8a6e869038ffe7a9d393521f
3
+ size 233799
requirements.txt CHANGED
@@ -1,3 +1,6 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
1
+ pandas==2.2.2
2
+ numpy==2.0.2
3
+ scikit-learn==1.6.1
4
+ xgboost==2.1.4
5
+ joblib==1.4.2
6
+ streamlit==1.43.2