Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse filesFiles changed (4)
- Dockerfile+9-13
- app.pyAdded+47
- rental_price_prediction_model_v1_0.joblibAdded+3
- requirements.txt+6-3
1234567891011121314151617181920FROM python:3.13.5-slimWORKDIR /appRUN apt-get update && apt-get install -y \build-essential \curl \git \&& rm -rf /var/lib/apt/lists/*COPY requirements.txt ./COPY src/ ./src/RUN pip3 install -r requirements.txtEXPOSE 8501HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/healthENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]12345678910111213141516# Use a minimal base image with Python 3.9 installedFROM python:3.9-slim# Set the working directory inside the container to /appWORKDIR /app# Copy all files from the current directory on the host to the container's /app directoryCOPY . .# Install Python dependencies listed in requirements.txtRUN pip3 install -r requirements.txt# Define the command to run the Streamlit app on port 8501 and make it accessible externallyCMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]# NOTE: Disable XSRF protection for easier external access in order to make batch predictions
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
import streamlit as stimport pandas as pdimport joblibimport numpy as np
# Load the trained model@st.cache_resourcedef load_model(): return joblib.load("rental_price_prediction_model_v1_0.joblib")
model = load_model()
# Streamlit UI for Price Predictionst.title("Airbnb Rental Price Prediction App")st.write("This tool predicts the price of an Airbnb listing based on the property details.")
st.subheader("Enter the listing details:")
# Collect user inputroom_type = st.selectbox("Room Type", ["Entire home/apt", "Private room", "Shared room"])accommodates = st.number_input("Accommodates (Number of guests)", min_value=1, value=2)bathrooms = st.number_input("Bathrooms", min_value=1, step=1, value=2)cancellation_policy = st.selectbox("Cancellation Policy (kind of cancellation policy)", ["strict", "flexible", "moderate"])cleaning_fee = st.selectbox("Cleaning Fee Charged?", ["True", "False"])instant_bookable = st.selectbox("Instantly Bookable?", ["False", "True"])review_scores_rating = st.number_input("Review Score Rating", min_value=0.0, max_value=100.0, step=1.0, value=90.0)bedrooms = st.number_input("Bedrooms", min_value=0, step=1, value=1)beds = st.number_input("Beds", min_value=0, step=1, value=1)
# Convert user input into a DataFrameinput_data = pd.DataFrame([{ 'room_type': room_type, 'accommodates': accommodates, 'bathrooms': bathrooms, 'cancellation_policy': cancellation_policy, 'cleaning_fee': cleaning_fee, 'instant_bookable': 'f' if instant_bookable=="False" else "t", 'review_scores_rating': review_scores_rating, 'bedrooms': bedrooms, 'beds': beds}])
# Predict buttonif st.button("Predict"): prediction = model.predict(input_data) st.write(f"The predicted price of the rental property is ${np.exp(prediction)[0]:.2f}.")123version https://git-lfs.github.com/spec/v1oid sha256:185811ffbf405f713dff5bb8b23ec8bfd29b3119373c66e4d530f5fbcfcfe143size 232032123altairpandasstreamlit123456pandas==2.2.2numpy==2.0.2scikit-learn==1.6.1xgboost==2.1.4joblib==1.4.2streamlit==1.43.2
Dockerfile+9-13
app.pyAdded+47
rental_price_prediction_model_v1_0.joblibAdded+3
requirements.txt+6-3