Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +47 -0
- rental_price_prediction_model_v1_0.joblib +3 -0
- requirements.txt +6 -3
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import joblib
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
# Load the trained model
|
| 8 |
+
@st.cache_resource
|
| 9 |
+
def load_model():
|
| 10 |
+
return joblib.load("rental_price_prediction_model_v1_0.joblib")
|
| 11 |
+
|
| 12 |
+
model = load_model()
|
| 13 |
+
|
| 14 |
+
# Streamlit UI for Price Prediction
|
| 15 |
+
st.title("Airbnb Rental Price Prediction App")
|
| 16 |
+
st.write("This tool predicts the price of an Airbnb listing based on the property details.")
|
| 17 |
+
|
| 18 |
+
st.subheader("Enter the listing details:")
|
| 19 |
+
|
| 20 |
+
# Collect user input
|
| 21 |
+
room_type = st.selectbox("Room Type", ["Entire home/apt", "Private room", "Shared room"])
|
| 22 |
+
accommodates = st.number_input("Accommodates (Number of guests)", min_value=1, value=2)
|
| 23 |
+
bathrooms = st.number_input("Bathrooms", min_value=1, step=1, value=2)
|
| 24 |
+
cancellation_policy = st.selectbox("Cancellation Policy (kind of cancellation policy)", ["strict", "flexible", "moderate"])
|
| 25 |
+
cleaning_fee = st.selectbox("Cleaning Fee Charged?", ["True", "False"])
|
| 26 |
+
instant_bookable = st.selectbox("Instantly Bookable?", ["False", "True"])
|
| 27 |
+
review_scores_rating = st.number_input("Review Score Rating", min_value=0.0, max_value=100.0, step=1.0, value=90.0)
|
| 28 |
+
bedrooms = st.number_input("Bedrooms", min_value=0, step=1, value=1)
|
| 29 |
+
beds = st.number_input("Beds", min_value=0, step=1, value=1)
|
| 30 |
+
|
| 31 |
+
# Convert user input into a DataFrame
|
| 32 |
+
input_data = pd.DataFrame([{
|
| 33 |
+
'room_type': room_type,
|
| 34 |
+
'accommodates': accommodates,
|
| 35 |
+
'bathrooms': bathrooms,
|
| 36 |
+
'cancellation_policy': cancellation_policy,
|
| 37 |
+
'cleaning_fee': cleaning_fee,
|
| 38 |
+
'instant_bookable': 'f' if instant_bookable=="False" else "t",
|
| 39 |
+
'review_scores_rating': review_scores_rating,
|
| 40 |
+
'bedrooms': bedrooms,
|
| 41 |
+
'beds': beds
|
| 42 |
+
}])
|
| 43 |
+
|
| 44 |
+
# Predict button
|
| 45 |
+
if st.button("Predict"):
|
| 46 |
+
prediction = model.predict(input_data)
|
| 47 |
+
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 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|