rashmicv09 commited on
Commit
b4e533b
·
verified ·
1 Parent(s): d9ff150

Upload folder using huggingface_hub

Browse files
Dockerfile CHANGED
@@ -1,20 +1,16 @@
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 -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"]
 
15
 
16
+ # NOTE: Disable XSRF protection for easier external access in order to make batch predictions
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import joblib
5
+ import numpy as np
6
+
7
+ #token = os.getenv("HF_TOKEN")
8
+ st.text("loading")
9
+
10
+ # Load the trained model
11
+ @st.cache_resource
12
+ def load_model():
13
+ return joblib.load("rental_price_prediction_model_v1_0.joblib")
14
+
15
+ model = load_model()
16
+
17
+ # Streamlit UI for Price Prediction
18
+ st.title("Airbnb Rental Price Prediction App")
19
+ st.write("This tool predicts the price of an Airbnb listing based on the property details.")
20
+
21
+ st.subheader("Enter the listing details:")
22
+
23
+ # Collect user input
24
+ room_type = st.selectbox("Room Type", ["Entire home/apt", "Private room", "Shared room"])
25
+ accommodates = st.number_input("Accommodates (Number of guests)", min_value=1, value=2)
26
+ bathrooms = st.number_input("Bathrooms", min_value=1, step=1, value=2)
27
+ cancellation_policy = st.selectbox("Cancellation Policy (kind of cancellation policy)", ["strict", "flexible", "moderate"])
28
+ cleaning_fee = st.selectbox("Cleaning Fee Charged?", ["True", "False"])
29
+ instant_bookable = st.selectbox("Instantly Bookable?", ["False", "True"])
30
+ review_scores_rating = st.number_input("Review Score Rating", min_value=0.0, max_value=100.0, step=1.0, value=90.0)
31
+ bedrooms = st.number_input("Bedrooms", min_value=0, step=1, value=1)
32
+ beds = st.number_input("Beds", min_value=0, step=1, value=1)
33
+
34
+ # Convert user input into a DataFrame
35
+ input_data = pd.DataFrame([{
36
+ 'room_type': room_type,
37
+ 'accommodates': accommodates,
38
+ 'bathrooms': bathrooms,
39
+ 'cancellation_policy': cancellation_policy,
40
+ 'cleaning_fee': cleaning_fee,
41
+ 'instant_bookable': 'f' if instant_bookable=="False" else "t",
42
+ 'review_scores_rating': review_scores_rating,
43
+ 'bedrooms': bedrooms,
44
+ 'beds': beds
45
+ }])
46
+
47
+ # Predict button
48
+ if st.button("Predict"):
49
+ prediction = model.predict(input_data)
50
+ st.write(f"The predicted price of the rental property is ${np.exp(prediction)[0]:.2f}.")
rental_price_prediction_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:764166bd669a86d5abd03fcec2411f6c23ccb7539f55b03bf4661346182d7556
3
+ size 232512
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