Fitjv's picture
Update app.py
149d299 verified
import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download
# -----------------------------
# Load model from Hugging Face
# -----------------------------
model_file = hf_hub_download(
repo_id="Fitjv/tourism-model",
filename="tourism_model_xgb.joblib"
)
model = joblib.load(model_file)
st.title("Tourism Customer Prediction")
st.write("Predict whether a customer will take the offered product.")
# -----------------------------
# Input form
# -----------------------------
with st.form("customer_form"):
Age = st.number_input("Age", min_value=18, max_value=100, value=30)
MonthlyIncome = st.number_input("Monthly Income", min_value=1000, max_value=1000000, value=50000)
DurationOfPitch = st.number_input("Duration Of Pitch (minutes)", min_value=1, max_value=120, value=10)
NumberOfTrips = st.number_input("Number of Trips", min_value=0, max_value=50, value=2)
Gender = st.selectbox("Gender", ["Male", "Female"])
NumberOfPersonVisiting = st.number_input("Number of Persons Visiting", 0, 10, 1)
NumberOfFollowups = st.number_input("Number of Followups", 0, 10, 1)
PreferredPropertyStar = st.number_input("Preferred Property Star", 1, 7, 3)
PitchSatisfactionScore = st.number_input("Pitch Satisfaction Score", 1, 10, 5)
NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", 0, 5, 0)
Occupation = st.selectbox("Occupation", ["Salaried", "Business", "Self-Employed", "Other"])
MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
TypeofContact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Agent", "Others"])
ProductPitched = st.selectbox("Product Pitched", ["ProductA", "ProductB", "ProductC"])
Designation = st.selectbox("Designation", ["Manager", "Executive", "Other"])
Passport = st.selectbox("Passport", ["Yes", "No"])
OwnCar = st.selectbox("Own Car", ["Yes", "No"])
CityTier = st.selectbox("City Tier", [1, 2, 3])
submitted = st.form_submit_button("Predict")
if submitted:
input_df = pd.DataFrame([{
"Age": Age,
"MonthlyIncome": MonthlyIncome,
"DurationOfPitch": DurationOfPitch,
"NumberOfTrips": NumberOfTrips,
"Gender": Gender,
"NumberOfPersonVisiting": NumberOfPersonVisiting,
"NumberOfFollowups": NumberOfFollowups,
"PreferredPropertyStar": PreferredPropertyStar,
"PitchSatisfactionScore": PitchSatisfactionScore,
"NumberOfChildrenVisiting": NumberOfChildrenVisiting,
"Occupation": Occupation,
"MaritalStatus": MaritalStatus,
"TypeofContact": TypeofContact,
"ProductPitched": ProductPitched,
"Designation": Designation,
"Passport": Passport,
"OwnCar": OwnCar,
"CityTier": CityTier
}])
prediction = model.predict(input_df)[0]
st.success(f"Prediction: {prediction}")