CoolFace
Apppublic

sahilsingla/GL_model_docker

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py48 linesDownload Raw Back to root
1 2import streamlit as st3import pandas as pd4import joblib5import numpy as np6 7# Load the trained model8@st.cache_resource9def load_model():10    return joblib.load("rental_price_prediction_model_v1_0.joblib")11 12model = load_model()13 14# Streamlit UI for Price Prediction15st.title("Airbnb Rental Price Prediction App")16st.write("This tool predicts the price of an Airbnb listing based on the property details.")17 18st.subheader("Enter the listing details:")19 20# Collect user input21room_type = st.selectbox("Room Type", ["Entire home/apt", "Private room", "Shared room"])22accommodates = st.number_input("Accommodates (Number of guests)", min_value=1, value=2)23bathrooms = st.number_input("Bathrooms", min_value=1, step=1, value=2)24cancellation_policy = st.selectbox("Cancellation Policy (kind of cancellation policy)", ["strict", "flexible", "moderate"])25cleaning_fee = st.selectbox("Cleaning Fee Charged?", ["True", "False"])26instant_bookable = st.selectbox("Instantly Bookable?", ["False", "True"])27review_scores_rating = st.number_input("Review Score Rating", min_value=0.0, max_value=100.0, step=1.0, value=90.0)28bedrooms = st.number_input("Bedrooms", min_value=0, step=1, value=1)29beds = st.number_input("Beds", min_value=0, step=1, value=1)30 31# Convert user input into a DataFrame32input_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': beds42}])43 44# Predict button45if 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}.")48