Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| import pickle | |
| import numpy as py | |
| import streamlit as st | |
| import gdown | |
| # File IDs | |
| model_id = "1HSQTjJ_hvBBmVJmYUmrkq5T7ubpfDwzF" | |
| top_country_id = "1aLkaAqfrs3GcrMvZcuyQ0NjFhAhrdIlR" | |
| model_url = f"https://drive.google.com/uc?id={model_id}" | |
| top_country_url = f"https://drive.google.com/uc?id={top_country_id}" | |
| def load_model(): | |
| gdown.download(model_url, "best_rf_model.pkl", quiet=False) | |
| with open("best_rf_model.pkl", "rb") as f: | |
| return pickle.load(f) | |
| def load_top_country(): | |
| gdown.download(top_country_url, "top_country.pkl", quiet=False) | |
| with open("top_country.pkl", "rb") as f: | |
| return pickle.load(f) | |
| model = load_model() | |
| top_country = load_top_country() | |
| # Load | |
| def run(): | |
| with st.form(key="hotel_bookings"): | |
| name = st.selectbox("Hotel Type", ("city_hotel", "resort_hotel"), index=0) | |
| lead = st.number_input( | |
| "Lead Time", | |
| min_value=0, | |
| max_value=600, | |
| value=0, | |
| step=1, | |
| help="jarak antar waktu booking dan check-in", | |
| ) | |
| arrival_year = st.selectbox("Arrival Year", ("2015", "2016", "2017"), index=0) | |
| arrival_month = st.selectbox( | |
| "Arrival Months", | |
| ( | |
| "January", | |
| "February", | |
| "March", | |
| "April", | |
| "May", | |
| "June", | |
| "July", | |
| "August", | |
| "September", | |
| "October", | |
| "November", | |
| "December", | |
| ), | |
| index=0, | |
| ) | |
| arrival_week = st.number_input( | |
| "Arrival Weeks", | |
| min_value=1, | |
| max_value=52, | |
| value=1, | |
| step=1, | |
| help="minggu kedatangan", | |
| ) | |
| arrival_day = st.number_input( | |
| "Arrival Days", | |
| min_value=1, | |
| max_value=31, | |
| value=1, | |
| step=1, | |
| help="tanggal kedatangan", | |
| ) | |
| submitted = st.form_submit_button("Predict") | |
| if __name__ == "_main_": | |
| run() | |