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="msubburao/Tourism-Package-model", filename="best_tourism_model_v1.joblib") # Load the model model = joblib.load(model_path) # Streamlit UI for Tourism Package Prediction st.title("Tourism Package Prediction App") st.write("The Tourism Package Prediction App is an tool that predicts whether a customer will purchase the newly introduced Tourism Package") st.write("Kindly enter the customer details to check whether they are likely to purchase the package.") # Collect user input Age = st.number_input("Age", min_value=18, max_value=100, value=30) Gender = st.selectbox("Gender", ["Male", "Female"]) TypeofContact = st.selectbox("Type of Contact",["Company Invited", "Self Inquiry"]) CityTier = st.selectbox("City Tier", [1, 2, 3]) Occupation = st.selectbox("Occupation",["Salaried", "Freelancer", "Small Business", "Large Business"]) NoOfPersonVisiting = st.number_input("Number of Persons Visiting",min_value=1, max_value=10, value=2) PreferredPropertyStar = st.selectbox("Preferred Property Star",[1, 2, 3, 4, 5]) MaritalStatus = st.selectbox("Marital Status",["Single", "Married", "Divorced"]) NoOfTrips = st.number_input("Number of Trips (per year)",min_value=0, max_value=50, value=2) Passport = st.selectbox("Has Passport?", ["Yes", "No"]) OwnCar = st.selectbox("Owns a Car?", ["Yes", "No"]) NoOfChildrenVisiting = st.number_input("Number of Children Visiting",min_value=0, max_value=5, value=0) Designation = st.selectbox("Designation",["Executive", "Manager", "Senior Manager", "VP"]) MonthlyIncome = st.number_input("Monthly Income",min_value=5000, max_value=500000, value=50000) PitchSatisfactionScore = st.slider("Pitch Satisfaction Score",min_value=1, max_value=5, value=3) ProductPitched = st.selectbox("Product Pitched",["Basic", "Standard", "Deluxe", "Super Deluxe"]) NoOfFollowups = st.number_input("Number of Follow-ups",min_value=0, max_value=20, value=2) DurationOfPitch = st.number_input("Duration of Pitch (minutes)",min_value=1, max_value=120, value=15) # Convert categorical inputs to match model training input_data = pd.DataFrame([{ "Age": Age, "TypeofContact": TypeofContact, "CityTier": CityTier, "Occupation": Occupation, "Gender": Gender, "NumberOfPersonVisiting": NoOfPersonVisiting, "PreferredPropertyStar": PreferredPropertyStar, "MaritalStatus": MaritalStatus, "NumberOfTrips": NoOfTrips, "Passport": 1 if Passport == "Yes" else 0, "OwnCar": 1 if OwnCar == "Yes" else 0, "NumberOfChildrenVisiting": NoOfChildrenVisiting, "Designation": Designation, "MonthlyIncome": MonthlyIncome, "PitchSatisfactionScore": PitchSatisfactionScore, "ProductPitched": ProductPitched, "NumberOfFollowups": NoOfFollowups, "DurationOfPitch": DurationOfPitch }]) # Set the classification threshold classification_threshold = 0.5 # Predict button if st.button("Predict"): prediction_proba = model.predict_proba(input_data)[0, 1] prediction = (prediction_proba >= classification_threshold).astype(int) if prediction == 1: st.success("The customer is likely to purchase the package.") else: st.error("The customer is unlikely to purchase the package.")