import streamlit as st import pandas as pd from datetime import datetime import joblib from sklearn.base import BaseEstimator, from datetime import datetime # Load the trained model def load_model(): return joblib.load("src/best_model.joblib") model = load_model() # ------------------------------------------------- # Streamlit App Configuration # ------------------------------------------------- st.set_page_config( page_title="Wellness Tourism Package Purchase Predictor", layout="centered" ) st.title("Wellness Tourism Package Purchase Predictor") st.markdown(""" Predict whether a customer will purchase our newly launched **Wellness Tourism Package** based on demographic and interaction details. Fill in the fields below and click **Predict**. """) # ------------------------------------------------- # Customer Demographics Inputs # ------------------------------------------------- age = st.number_input("Age", min_value=18, max_value=100, value=30) gender = st.selectbox("Gender", ["Male", "Female"]) marital_status = st.selectbox("Marital Status", ["Single", "Married", "Divorced"]) occupation = st.selectbox( "Occupation", ["Salaried", "Freelancer", "Business", "Student", "Retired", "Other"] ) designation = st.text_input("Designation", value="") city_tier = st.selectbox("City Tier", [1, 2, 3]) monthly_income = st.number_input( "Monthly Income (Gross)", min_value=0, step=1000, value=50000 ) passport = st.selectbox("Valid Passport?", ["Yes", "No"]) own_car = st.selectbox("Owns a Car?", ["Yes", "No"]) number_of_persons = st.number_input( "Number of People Visiting", min_value=1, max_value=10, value=2 ) number_of_children = st.number_input( "Number of Children Under 5 Visiting", min_value=0, max_value=5, value=0 ) # ------------------------------------------------- # Customer Interaction Inputs # ------------------------------------------------- type_of_contact = st.selectbox( "Type of Contact", ["Company Invited", "Self Inquiry"] ) product_pitched = st.selectbox( "Product Pitched", ["Wellness Package", "Adventure Package", "Cultural Package", "Other"] ) pitch_satisfaction = st.slider( "Pitch Satisfaction Score", min_value=0, max_value=10, value=7 ) number_of_followups = st.number_input( "Number of Follow-ups", min_value=0, max_value=20, value=1 ) duration_of_pitch = st.number_input( "Duration of Pitch (minutes)", min_value=1, max_value=120, value=10 ) number_of_trips = st.number_input( "Average Number of Trips per Year", min_value=0, max_value=50, value=2 ) preferred_property_star = st.number_input( "Preferred Hotel Star Rating", min_value=1, max_value=5, value=3 ) # ------------------------------------------------- # Assemble Input DataFrame # ------------------------------------------------- input_df = pd.DataFrame([{ "Age": age, "Gender": gender, "MaritalStatus": marital_status, "Occupation": occupation, "Designation": designation, "CityTier": city_tier, "MonthlyIncome": monthly_income, "Passport": 1 if passport == "Yes" else 0, "OwnCar": 1 if own_car == "Yes" else 0, "NumberOfPersonVisiting": number_of_persons, "NumberOfChildrenVisiting": number_of_children, "TypeofContact": type_of_contact, "ProductPitched": product_pitched, "PitchSatisfactionScore": pitch_satisfaction, "NumberOfFollowups": number_of_followups, "DurationOfPitch": duration_of_pitch, "NumberOfTrips": number_of_trips, "PreferredPropertyStar": preferred_property_star }]) # ------------------------------------------------- # Prediction & Display # ------------------------------------------------- if st.button("Predict Purchase"): pred = model.predict(input_df)[0] label = "🚀 Will Purchase" if pred == 1 else "❌ Will Not Purchase" st.subheader("Prediction Result") st.success(label)