Spaces:
Sleeping
Sleeping
File size: 5,154 Bytes
40a9bc1 55b8c16 40a9bc1 55b8c16 40a9bc1 55b8c16 40a9bc1 9a5942b 55b8c16 40a9bc1 91f3db9 |
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
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="asvravi/asv-tourism-package", filename="best_toursim_package_model_v1.joblib")
model = joblib.load(model_path)
# Streamlit UI for Tourism Package Prediction
st.title("Tourism Package Prediction")
st.write("""
This application predicts the likelihood of a customer buying the new Tourism Package.
Please enter the data below to get a prediction.
""")
# User input
st.header("Section 1 β Basic Information")
# ---------- Row 1 ----------
col1, col2, col3, col7 = st.columns(4)
with col1:
age = st.number_input(
"Age",
min_value=1,
max_value=150,
value=25
)
with col2:
# Marital status alphabetically
marital_status_options = sorted(["Married", "Single", "Divorced", "Unmarried"])
marital_status = st.selectbox(
"Marital Status",
marital_status_options,
index=0
)
with col3:
gender = st.radio(
"Gender",
["Male", "Female"],
index=0
)
with col7:
own_car = st.selectbox(
"Own a Car",
["Yes", "No"],
index=0
)
# ---------- Row 2 ----------
col4, col5, col6 = st.columns(3)
with col4:
city_tier = st.selectbox(
"City Tier",
[1, 2, 3],
index=0
)
with col5:
total_family = st.number_input(
"Total Family Members",
min_value=1,
max_value=50,
value=1,
step=1
)
with col6:
children = st.number_input(
"No. of Children (age > 5)",
min_value=0,
max_value=20,
value=0,
step=1
)
st.header("Section 2 β Professional Details")
# ---------- Row 1 ----------
col1, col2, col3 = st.columns(3)
with col1:
occupation_options = sorted(["Free Lancer", "Salaried", "Large Business", "Small Business"])
occupation = st.selectbox(
"Occupation",
occupation_options,
index=0
)
with col2:
designation_options = sorted(["AVP", "Manager", "Senior Manager", "Executive", "VP"])
designation = st.selectbox(
"Designation",
designation_options,
index=0
)
with col3:
monthly_salary = st.number_input(
"Monthly Salary",
min_value=1000,
max_value=100000,
value=1000,
step=100
)
st.header("Section 3 β Travel Preferences")
# ---------- Row 1 ----------
col1, col2, col3 = st.columns(3)
with col1:
property_star = st.selectbox(
"Preferred Property Star",
[3, 4, 5],
index=0
)
with col2:
trips_per_year = st.number_input(
"Number of Trips per Year",
min_value=1,
max_value=50,
value=1,
step=1
)
with col3:
passport = st.selectbox(
"Passport",
["Yes", "No"],
index=0
)
st.header("Section 4 β Sales Interaction Details")
# ---------- Row 1 ----------
col1, col2, col3 = st.columns(3)
with col1:
type_of_contact = st.selectbox(
"Type of Contact",
["Company Invited", "Self Enquiry"],
index=0
)
with col2:
product_pitched = st.selectbox(
"Product Pitched",
["Basic", "Deluxe", "King", "Standard", "Super Deluxe"],
index=0
)
with col3:
pitch_duration = st.number_input(
"Duration of Pitch (minutes)",
min_value=1,
max_value=150,
value=1,
step=1
)
# ---------- Row 2 ----------
col4, col5, col6 = st.columns(3)
with col4:
followups = st.number_input(
"Number of Follow-ups",
min_value=1,
max_value=10,
value=1,
step=1
)
with col5:
pitch_satisfaction = st.selectbox(
"Pitch Satisfaction Score",
[1, 2, 3, 4, 5],
index=0
)
own_car = 1 if own_car == "Yes" else 0
passport = 1 if passport == "Yes" else 0
# Assemble input into DataFrame
input_data = pd.DataFrame([{
'Age': age,
'DurationOfPitch': pitch_duration,
'NumberOfFollowups': followups,
'PitchSatisfactionScore': pitch_satisfaction,
'NumberOfPersonVisiting': total_family,
'PreferredPropertyStar': property_star,
'NumberOfTrips': trips_per_year,
'Passport': passport,
'OwnCar': own_car,
'NumberOfChildrenVisiting': children,
'MonthlyIncome': monthly_salary,
'CityTier': city_tier,
'TypeofContact': type_of_contact,
'Occupation': occupation,
'Gender': gender,
'ProductPitched': product_pitched,
'MaritalStatus': marital_status,
'Designation': designation
}])
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 = "likely to buy" if prediction == 1 else "not likely to buy"
st.subheader("Prediction Result")
st.markdown(
f"Based on the information provided, the customer is **{result}** the new tourism package."
)
|