tourism-project / app.py
papsofts's picture
Upload folder using huggingface_hub
5f3b056 verified
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib
# Download the model from the Model Hub
model_path = hf_hub_download(repo_id="papsofts/tourism-project", filename="best_tourism_model_v1.joblib")
# Load the model
model = joblib.load(model_path)
# Streamlit UI for Customer Churn Prediction
st.title("Wellness Tourism Package Prediction App")
st.write("The Wellness Tourism Package Prediction App is an internal tool for the tourism staff that predicts whether customers who might choose the wellness tour package based on their details.")
st.write("Kindly enter the customer details to check whether they are likely to choose the wellness tourism package.")
# Collect user input
Age = st.number_input("Age (customer's age in years)", min_value=18, max_value=100, value=30)
TypeofContact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"])
CityTier = st.selectbox("City Tier", options=[1, 2, 3], format_func=lambda x: f"Tier {x}")
Occupation = st.selectbox("Occupation", ["Salaried", "Free Lancer", "Small Business", "Large Business"])
Gender = st.selectbox("Gender", ["Male", "Female"])
NumberOfPersonVisiting = st.number_input("Number of People Visiting", min_value=1, max_value=10, value=2)
PreferredPropertyStar = st.number_input("Preferred Property Star", min_value=1, max_value=5, value=4)
MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced", "Unmarried"])
NumberOfTrips = st.number_input("Number of Trips", min_value=1, max_value=50, value=2)
Passport = st.selectbox("Passport", options=[0, 1], format_func=lambda x: "Yes" if x == 1 else "No")
OwnCar = st.selectbox("Own Car", options=[0, 1], format_func=lambda x: "Yes" if x == 1 else "No")
NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, max_value=5, value=0)
Designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "VP", "AVP"])
MonthlyIncome = st.number_input("Monthly Income", min_value=0, value=15000)
st.write("Kindly enter the customer interaction details below:")
PitchSatisfactionScore = st.number_input("Pitch Satisfaction Score", min_value=1, max_value=5, value=3)
ProductPitched = st.selectbox("Product Pitched", ["Basic", "Deluxe", "King", "Standard", "Super Deluxe"])
NumberOfFollowups = st.number_input("Number of Follow-ups", min_value=0, value=2)
DurationOfPitch = st.number_input("Duration of Pitch", min_value=0, value=3)
# Convert categorical inputs to match model training
input_data = pd.DataFrame([{
'Age': Age,
'TypeofContact': TypeofContact,
'CityTier': CityTier,
'Occupation': Occupation,
'Gender': Gender,
'NumberOfPersonVisiting': NumberOfPersonVisiting,
'PreferredPropertyStar': PreferredPropertyStar,
'MaritalStatus': MaritalStatus,
'NumberOfTrips': NumberOfTrips,
'Passport': Passport,
'OwnCar': OwnCar,
'NumberOfChildrenVisiting': NumberOfChildrenVisiting,
'Designation': Designation,
'MonthlyIncome': MonthlyIncome,
'PitchSatisfactionScore': PitchSatisfactionScore,
'ProductPitched': ProductPitched,
'NumberOfFollowups': NumberOfFollowups,
'DurationOfPitch': DurationOfPitch
}])
# Set the classification threshold
classification_threshold = 0.45
# Predict button
if st.button("Predict"):
prediction_proba = model.predict_proba(input_data)[0, 1]
prediction = (prediction_proba >= classification_threshold).astype(int)
result = "purchase the package" if prediction == 1 else "not purchase the package"
st.write(f"Based on the information provided, the customer is likely to {result}.")