import streamlit as st import pandas as pd import joblib from huggingface_hub import hf_hub_download # ================= Load Model ================= model_path = hf_hub_download( repo_id="Disha252001/tourism-prediction-model", filename="best_model.joblib" ) model = joblib.load(model_path) st.title("Wellness Tourism Package Prediction") # ================= Encoding Maps ================= gender_map = {"Female": 0, "Male": 1} occupation_map = { "Free Lancer": 0, "Salaried": 1, "Small Business": 2 } marital_map = { "Single": 0, "Married": 1, "Divorced": 2 } # ================= User Inputs ================= Age = st.number_input("Age", 18, 80, 30) CityTier = st.selectbox("City Tier", [1, 2, 3]) Gender = st.selectbox("Gender", list(gender_map.keys())) Occupation = st.selectbox("Occupation", list(occupation_map.keys())) MaritalStatus = st.selectbox("Marital Status", list(marital_map.keys())) MonthlyIncome = st.number_input("Monthly Income", 10000, 500000, 50000) NumberOfTrips = st.number_input("Number of Trips per Year", 0, 20, 2) PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3) # ================= Build Input Row ================= input_data = { "Age": Age, "TypeofContact": 0, "CityTier": CityTier, "DurationOfPitch": 15, "Occupation": occupation_map[Occupation], "Gender": gender_map[Gender], "NumberOfPersonVisiting": 2, "NumberOfFollowups": 2, "ProductPitched": 0, "PreferredPropertyStar": 3, "MaritalStatus": marital_map[MaritalStatus], "NumberOfTrips": NumberOfTrips, "Passport": 1, "PitchSatisfactionScore": PitchSatisfactionScore, "OwnCar": 1, "NumberOfChildrenVisiting": 0, "Designation": 0, "MonthlyIncome": MonthlyIncome } input_df = pd.DataFrame([input_data]) # Handle accidental index column if "Unnamed: 0" in model.feature_names_in_: input_df["Unnamed: 0"] = 0 # Ensure correct order input_df = input_df[model.feature_names_in_] # ================= Predict ================= if st.button("Predict"): prediction = model.predict(input_df)[0] result = "Purchased Package" if prediction == 1 else "Did Not Purchase" st.success(f"Prediction Result: **{result}**")