File size: 3,176 Bytes
77cb43b 2a84eef 77cb43b 2a84eef 77cb43b 2a84eef 77cb43b 2a84eef 77cb43b 2c8a7a7 77cb43b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib
from config import HF_REPO_ID
# Download and load the model
model_path = hf_hub_download(repo_id=HF_REPO_ID, filename="best_tourism_package_prediction_model_v1.joblib")
model = joblib.load(model_path)
# Streamlit UI for Tourism Package Prediction...
st.title("Tour Package Prediction App")
st.write("""
This application predicts the likelihood of a customer selecting the package parameters.
Please enter the sensor and configuration data below to get a prediction.
""")
# User input
st.header("User Input")
Age = st.number_input("Age", min_value=10, max_value=100, value=30, step=1)
TypeofContact = st.selectbox("TypeofContact", ["Self Enquiry", "Company Invited"])
CityTier = st.selectbox("CityTier", ["Tier 1", "Tier 2", "Tier 3"])
Occupation = st.selectbox("Occupation", ["Salaried", "Freelancer"])
Gender = st.selectbox("Gender", ["Male", "Female"])
NumberOfPersonVisiting = st.number_input("Number of person visiting", min_value=1, max_value=10, value=2, step=1)
PreferredPropertyStar = st.number_input("Preferred Property Star", min_value=2, max_value=5, value=3, step=1)
MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
NumberOfTrips = st.number_input("Number of trips", min_value=1, max_value=10, value=2, step=1)
Passport = st.selectbox("Passport", ["Yes", "No"])
OwnCar = st.selectbox("Own Car", ["Yes", "No"])
NumberOfChildrenVisiting = st.number_input("Number of children visiting", min_value=0, max_value=5, value=0, step=1)
Designation = st.selectbox("Designation", ["Manager", "Executive", "Senior Manager", "VP"])
MonthlyIncome = st.number_input("Monthly Income", min_value=0, max_value=100000, value=50000, step=100)
PitchSatisfactionScore = st.number_input("Pitch Satisfaction Score", min_value=1, max_value=5, value=3, step=1)
NumberOfFollowups = st.number_input("Number of Followups", min_value=1, max_value=10, value=2, step=1)
DurationOfPitch = st.number_input("Duration of Pitch", min_value=1, max_value=100, value=30, step=1)
ProductPitched = st.selectbox("Product Pitched", ["Basic", "Deluxe", "Standard","Super Deluxe", "King"])
# Assemble input into DataFrame
input_data = pd.DataFrame([{
'Age': Age,
'TypeofContact': TypeofContact,
'CityTier': CityTier,
'DurationOfPitch': DurationOfPitch,
'Occupation': Occupation,
'Gender': Gender,
'NumberOfPersonVisiting': NumberOfPersonVisiting,
'NumberOfFollowups': NumberOfFollowups,
'ProductPitched': ProductPitched,
'PreferredPropertyStar': PreferredPropertyStar,
'MaritalStatus': MaritalStatus,
'NumberOfTrips': NumberOfTrips,
'Passport': Passport,
'PitchSatisfactionScore': PitchSatisfactionScore,
'OwnCar': OwnCar,
'NumberOfChildrenVisiting': NumberOfChildrenVisiting,
'Designation': Designation,
'MonthlyIncome': MonthlyIncome
}])
if st.button("Predict Failure"):
prediction = model.predict(input_data)[0]
result = "Package selected" if prediction == 1 else "Package not selected"
st.subheader("Prediction Result:")
st.success(f"The model predicts: **{result}**")
|