roshra's picture
Upload app.py with huggingface_hub
70ccb92 verified
# week_3_mls/deployment/app.py
import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download
# Load model from HF Hub
MODEL_REPO = "roshra/machine-failure-prediction"
MODEL_FILE = "tourism_clean_model.joblib"
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE, repo_type="space")
model = joblib.load(model_path)
st.title("🧳 Tourism Package Purchase Prediction App")
st.write("Fill in details to predict if the customer will purchase the package.")
# UI inputs
age = st.number_input("Age", 18, 100, 30)
duration = st.number_input("Trip Duration (days)", 1, 30, 5)
adults = st.number_input("Number of Adults", 1, 10, 2)
children = st.number_input("Number of Children", 0, 10, 0)
income = st.number_input("Monthly Income", 1000, 200000, 30000)
prop = st.selectbox("Preferred Property", ["Hotel", "Resort", "Guest House", "Other"])
travel = st.selectbox("Mode of Travel", ["Air", "Train", "Car", "Bus"])
gender = st.selectbox("Gender", ["Male", "Female", "Other"])
occupation = st.selectbox("Occupation", ["Salaried", "Self-Employed", "Business", "Other"])
marital = st.selectbox("Marital Status", ["Single", "Married", "Divorced", "Other"])
if st.button("Predict Purchase"):
input_df = pd.DataFrame([{
"Age": age,
"Duration": duration,
"NumberOfAdults": adults,
"NumberOfChildren": children,
"MonthlyIncome": income,
"PreferredProperty": prop,
"ModeOfTravel": travel,
"Gender": gender,
"Occupation": occupation,
"MaritalStatus": marital
}])
prediction = model.predict(input_df)[0]
if prediction == 1:
st.success("✅ Customer is likely to purchase the package!")
else:
st.error("❌ Customer is unlikely to purchase the package.")