File size: 3,434 Bytes
50cc466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib

# -------------------------------
# LOAD MODEL FROM HUGGING FACE HUB
# -------------------------------
model_path = hf_hub_download(
    repo_id="vsardey/tourism-package-prediction-model",
    filename="tourism-package-prediction_model.joblib"
)
model = joblib.load(model_path)

# -------------------------------
# STREAMLIT APP
# -------------------------------
st.title("Tourism Package Purchase Prediction App")

st.write("""
This application predicts whether a customer is likely to purchase the **Tourism Package**
offered by *Visit with Us*.

Please enter the customer details below to get the prediction.
""")

# -------------------------------
# USER INPUT FIELDS
# -------------------------------
Age = st.number_input("Customer Age", min_value=0, 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", "Self Employed", "Freelancer", "Company Owner", "Other"]
)

MaritalStatus = st.selectbox(
    "Marital Status",
    ["Single", "Married", "Divorced"]
)

ProductPitched = st.selectbox(
    "Product Pitched",
    ["Basic", "Deluxe", "Standard", "King", "Super Deluxe"]
)

Designation = st.selectbox(
    "Designation",
    ["Manager", "Executive", "Senior Manager", "AVP", "VP"]
)

MonthlyIncome = st.number_input("Monthly Income", min_value=0, value=50000)

NumberOfTrips = st.number_input("Average Trips per Year", min_value=0, value=1)

NumberOfPersonVisiting = st.number_input("Number of Persons Visiting", min_value=1, value=2)

PreferredPropertyStar = st.selectbox("Preferred Hotel Star Rating", [1, 2, 3, 4, 5])

NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, value=0)

Passport = st.selectbox("Passport Available?", [0, 1])

OwnCar = st.selectbox("Owns a Car?", [0, 1])

PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3)

NumberOfFollowups = st.number_input("Number of Follow-ups", min_value=0, value=2)

DurationOfPitch = st.number_input("Duration of Pitch (minutes)", min_value=0, value=15)

# -------------------------------
# CREATE INPUT DATAFRAME
# -------------------------------
input_data = pd.DataFrame([{
    "Age": Age,
    "Gender": Gender,
    "TypeofContact": TypeofContact,
    "CityTier": CityTier,
    "Occupation": Occupation,
    "MaritalStatus": MaritalStatus,
    "NumberOfPersonVisiting": NumberOfPersonVisiting,
    "PreferredPropertyStar": PreferredPropertyStar,
    "NumberOfTrips": NumberOfTrips,
    "Passport": Passport,
    "OwnCar": OwnCar,
    "NumberOfChildrenVisiting": NumberOfChildrenVisiting,
    "Designation": Designation,
    "MonthlyIncome": MonthlyIncome,
    "PitchSatisfactionScore": PitchSatisfactionScore,
    "ProductPitched": ProductPitched,
    "NumberOfFollowups": NumberOfFollowups,
    "DurationOfPitch": DurationOfPitch
}])

# -------------------------------
# PREDICTION
# -------------------------------
if st.button("Predict Purchase Likelihood"):
    prediction = model.predict(input_data)[0]
    result = "Will Purchase Package" if prediction == 1 else "Will Not Purchase Package"

    st.subheader("Prediction Result:")
    st.success(f"The model predicts: **{result}**")