File size: 3,592 Bytes
c6505c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98b2637
c6505c9
 
98b2637
 
c6505c9
 
 
98b2637
c6505c9
 
 
 
98b2637
 
c6505c9
 
 
98b2637
 
c6505c9
 
 
98b2637
c6505c9
 
 
98b2637
 
c6505c9
 
98b2637
 
c6505c9
 
98b2637
 
c6505c9
 
98b2637
c6505c9
 
 
 
98b2637
c6505c9
 
 
 
98b2637
c6505c9
 
 
 
98b2637
 
c6505c9
 
 
98b2637
 
 
 
 
 
 
 
 
 
 
c6505c9
 
98b2637
 
 
 
 
 
 
 
 
c6505c9
 
 
 
 
 
 
 
 
 
 
 
 
 
98b2637
 
 
 
 
 
c6505c9
 
 
 
 
 
 
 
 
 
 
 
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib

# Download the model from the Model Hub
model_path = hf_hub_download(repo_id="affanthinks/Tourism-Package-Prediction", filename="best_tourism_pred_model_v1.joblib")

# Load the model
model = joblib.load(model_path)

# Streamlit UI for Customer Churn Prediction
st.title("tourism Prediction App")
st.write("The tourism Prediction App is an internal tool for tourism staff that predicts whether customers are purchasing the product based on their details and pitch.")
st.write("Kindly enter the customer details to check whether they are likely to purchase.")

# Collect user input
Age = st.number_input("Age (Age of the customer)", min_value=18, max_value=120, value=30)

TypeofContact = st.selectbox(
    "Type of Contact",
    ["Self Enquiry", "Company Invited"]
)

CityTier = st.selectbox(
    "City Tier",
    [1, 2, 3]
)

Occupation = st.selectbox(
    "Occupation",
    ["Salaried", "Free Lancer", "Small Business", "Large Business"]
)

Gender = st.selectbox(
    "Gender",
    ["Female", "Male", "Fe Male"]
)

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

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


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

NumberOfTrips = st.number_input("Number of Trips Annually", min_value=1, max_value=22, value=1)


Passport = st.selectbox(
    "Passport",
    ["Yes", "No"]
)

OwnCar = st.selectbox(
    "Own Car",
    ["Yes", "No"]
)

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

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

MonthlyIncome = st.number_input(
    "Monthly Income",
    min_value=1000.0, value=50000.0
)

# NEW REQUIRED FIELDS
PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3)


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

NumberOfFollowups = st.number_input(
    "Number Of Follow-ups",
    min_value=0, max_value=50, value=1
)

DurationOfPitch = st.number_input("Duration of Pitch (minutes)", min_value=5, max_value=127, value=10)


# Create dataframe for model
input_data = pd.DataFrame([{
    'Age': Age,
    'TypeofContact': TypeofContact,
    'CityTier': CityTier,
    'Occupation': Occupation,
    'Gender': Gender,
    'NumberOfPersonVisiting': NumberOfPersonVisiting,
    'PreferredPropertyStar': PreferredPropertyStar,
    'MaritalStatus': MaritalStatus,
    'NumberOfTrips': NumberOfTrips,
    'Passport': 1 if Passport == "Yes" else 0,
    'OwnCar': 1 if OwnCar == "Yes" else 0,
    'NumberOfChildrenVisiting': NumberOfChildrenVisiting,
    'Designation': Designation,
    'MonthlyIncome': MonthlyIncome,
    # REQUIRED new fields
    'PitchSatisfactionScore': PitchSatisfactionScore,
    'ProductPitched': ProductPitched,
    'NumberOfFollowups': NumberOfFollowups,
    'DurationOfPitch': DurationOfPitch
}])


# Set the classification threshold
classification_threshold = 0.45

# Predict button
if st.button("Predict"):
    prediction_proba = model.predict_proba(input_data)[0, 1]
    prediction = (prediction_proba >= classification_threshold).astype(int)
    result = "purchase" if prediction == 1 else "not purchase"
    st.write(f"Based on the information provided, the customer is likely to {result}.")