import streamlit as st import pandas as pd from huggingface_hub import hf_hub_download import joblib # Download and load the model model_path = hf_hub_download(repo_id="KishoreKT/tourism_study_model", filename="best_tourism_study_model_v1.joblib") model = joblib.load(model_path) # Streamlit UI for Machine Failure Prediction st.title("Tourism Study App") st.write(""" This application predicts the likelihood of a user opting to choose a tourism package. Please enter the relevant data below to get a prediction. """) # User input age = st.number_input("Age", min_value=18, max_value=100, value=35) type_of_contact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"]) city_tier = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"]) occupation = st.selectbox("Occupation", ["Salaried", "Small Business", "Large Business", "Freelancer"]) gender = st.selectbox("Gender", ["Male", "Female"]) number_of_person_visiting = st.number_input("Number of Persons Visiting", min_value=1, max_value=10, value=2) preferred_property_star = st.selectbox("Preferred Property Star", [3, 4, 5]) marital_status = st.selectbox("Marital Status", ["Single", "Married", "Divorced"]) number_of_trips = st.number_input("Number of Trips (Annual)", min_value=0, max_value=20, value=3) passport = st.selectbox("Passport", ["Yes", "No"]) own_car = st.selectbox("Own Car", ["Yes", "No"]) number_of_children_visiting = st.number_input("Number of Children Visiting", min_value=0, max_value=5, value=0) designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP", "VP"]) monthly_income = st.number_input("Monthly Income", min_value=0, max_value=200000, value=25000, step=1000) # Customer Interaction Data pitch_satisfaction_score = st.slider("Pitch Satisfaction Score", min_value=1, max_value=5, value=3) product_pitched = st.selectbox("Product Pitched", ["Basic", "Standard", "Deluxe", "Super Deluxe", "King"]) number_of_followups = st.number_input("Number of Follow-ups", min_value=0, max_value=10, value=3) duration_of_pitch = st.number_input("Duration of Pitch (minutes)", min_value=5, max_value=120, value=30) # Assemble input into DataFrame input_data = pd.DataFrame([{ 'Age': age, 'TypeofContact': type_of_contact, 'CityTier': city_tier, 'Occupation': occupation, 'Gender': gender, 'NumberOfPersonVisiting': number_of_person_visiting, 'PreferredPropertyStar': preferred_property_star, 'MaritalStatus': marital_status, 'NumberOfTrips': number_of_trips, 'Passport': 1 if passport == "Yes" else 0, 'OwnCar': 1 if own_car == "Yes" else 0, 'NumberOfChildrenVisiting': number_of_children_visiting, 'Designation': designation, 'MonthlyIncome': monthly_income, 'PitchSatisfactionScore': pitch_satisfaction_score, 'ProductPitched': product_pitched, 'NumberOfFollowups': number_of_followups, 'DurationOfPitch': duration_of_pitch }]) if st.button("Predict User Choice for Opting Package"): prediction = model.predict(input_data)[0] result = "User Opt is YES" if prediction == 1 else "User Opt is NO" st.subheader("Prediction Result:") st.success(f"The model predicts: **{result}**")