Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +1 -1
- app.py +26 -27
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# Use a minimal base image with Python 3.9 installed
|
| 2 |
-
FROM python:3.9
|
| 3 |
|
| 4 |
# Set the working directory inside the container to /app
|
| 5 |
WORKDIR /app
|
|
|
|
| 1 |
# Use a minimal base image with Python 3.9 installed
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory inside the container to /app
|
| 5 |
WORKDIR /app
|
app.py
CHANGED
|
@@ -9,12 +9,12 @@ import joblib
|
|
| 9 |
st.set_page_config(page_title="Tourism Package Prediction", page_icon="๐", layout="centered")
|
| 10 |
|
| 11 |
st.title("๐ Tourism Package Prediction App")
|
| 12 |
-
st.
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
# ================================
|
| 20 |
# Load Model from Hugging Face Hub
|
|
@@ -29,41 +29,42 @@ def load_model():
|
|
| 29 |
|
| 30 |
model = load_model()
|
| 31 |
|
| 32 |
-
# Mapping for City Tier
|
| 33 |
city_tier_map = {"Tier 1": 1, "Tier 2": 2, "Tier 3": 3}
|
| 34 |
|
| 35 |
# ================================
|
| 36 |
-
#
|
| 37 |
# ================================
|
| 38 |
-
st.
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
age = st.number_input("Age of Customer", min_value=18, max_value=100, value=30)
|
| 43 |
gender = st.selectbox("Gender", ["Female", "Male"])
|
| 44 |
marital_status = st.selectbox("Marital Status", ["Single", "Divorced", "Married", "Unmarried"])
|
| 45 |
occupation = st.selectbox("Occupation", ["Salaried", "Free Lancer", "Small Business", "Large Business"])
|
| 46 |
designation = st.selectbox("Designation", ["Manager", "Executive", "Senior Manager", "AVP", "VP"])
|
| 47 |
city_tier = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
|
| 48 |
-
|
| 49 |
-
with
|
| 50 |
monthly_income = st.number_input("Monthly Income", min_value=100, max_value=200000, value=10000)
|
| 51 |
-
own_car = st.radio("Owns a Car?", ["Yes", "No"])
|
| 52 |
-
passport = st.radio("Has Passport?", ["Yes", "No"])
|
| 53 |
|
| 54 |
-
|
| 55 |
-
with st.sidebar.expander("โ๏ธ Travel Preferences", expanded=False):
|
| 56 |
product_pitched = st.selectbox("Product Pitched", ["Deluxe", "Basic", "Standard", "Super Deluxe", "King"])
|
| 57 |
preferred_property_star = st.selectbox("Preferred Property Star", [3, 4, 5])
|
| 58 |
|
| 59 |
-
|
| 60 |
-
with st.sidebar.expander("๐จโ๐ฉโ๐ง Family & Trips", expanded=False):
|
| 61 |
num_person_visiting = st.number_input("Number of Persons Visiting", min_value=1, max_value=5, value=1)
|
| 62 |
num_children_visiting = st.number_input("Number of Children Visiting", min_value=0, max_value=3, value=0)
|
| 63 |
num_trips = st.number_input("Number of Trips", min_value=1, max_value=22, value=3)
|
| 64 |
|
| 65 |
-
|
| 66 |
-
with st.sidebar.expander("๐ Sales Interaction", expanded=False):
|
| 67 |
type_of_contact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
|
| 68 |
duration_of_pitch = st.number_input("Pitch Duration (minutes)", min_value=0, max_value=150, value=30)
|
| 69 |
num_followups = st.number_input("Number of Followups", min_value=1, max_value=6, value=1)
|
|
@@ -96,18 +97,16 @@ input_data = pd.DataFrame([{
|
|
| 96 |
# ================================
|
| 97 |
# Prediction
|
| 98 |
# ================================
|
| 99 |
-
|
| 100 |
-
# Classification threshold used during training
|
| 101 |
CLASSIFICATION_THRESHOLD = 0.45
|
| 102 |
|
| 103 |
-
if st.button("๐ฎ Predict"):
|
| 104 |
-
|
| 105 |
-
proba = model.predict_proba(input_data)[0][1]
|
| 106 |
prediction = 1 if proba >= CLASSIFICATION_THRESHOLD else 0
|
| 107 |
|
| 108 |
result = "โ
Package Opted" if prediction == 1 else "โ Package Not Opted"
|
| 109 |
-
confidence =
|
| 110 |
|
|
|
|
| 111 |
st.subheader("๐ Prediction Result")
|
| 112 |
st.success(f"**{result}** with {confidence}% confidence")
|
| 113 |
|
|
|
|
| 9 |
st.set_page_config(page_title="Tourism Package Prediction", page_icon="๐", layout="centered")
|
| 10 |
|
| 11 |
st.title("๐ Tourism Package Prediction App")
|
| 12 |
+
st.markdown(
|
| 13 |
"""
|
| 14 |
+
Provide customer details below to predict whether they are likely to
|
| 15 |
+
**opt for a tourism package**.
|
| 16 |
+
"""
|
| 17 |
+
)
|
| 18 |
|
| 19 |
# ================================
|
| 20 |
# Load Model from Hugging Face Hub
|
|
|
|
| 29 |
|
| 30 |
model = load_model()
|
| 31 |
|
|
|
|
| 32 |
city_tier_map = {"Tier 1": 1, "Tier 2": 2, "Tier 3": 3}
|
| 33 |
|
| 34 |
# ================================
|
| 35 |
+
# Tabs for Input Sections
|
| 36 |
# ================================
|
| 37 |
+
tabs = st.tabs([
|
| 38 |
+
"๐ค Personal Information",
|
| 39 |
+
"๐ฐ Lifestyle & Financial",
|
| 40 |
+
"โ๏ธ Travel Preferences",
|
| 41 |
+
"๐จโ๐ฉโ๐ง Family & Trips",
|
| 42 |
+
"๐ Sales Interaction"
|
| 43 |
+
])
|
| 44 |
+
|
| 45 |
+
with tabs[0]:
|
| 46 |
age = st.number_input("Age of Customer", min_value=18, max_value=100, value=30)
|
| 47 |
gender = st.selectbox("Gender", ["Female", "Male"])
|
| 48 |
marital_status = st.selectbox("Marital Status", ["Single", "Divorced", "Married", "Unmarried"])
|
| 49 |
occupation = st.selectbox("Occupation", ["Salaried", "Free Lancer", "Small Business", "Large Business"])
|
| 50 |
designation = st.selectbox("Designation", ["Manager", "Executive", "Senior Manager", "AVP", "VP"])
|
| 51 |
city_tier = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
|
| 52 |
+
|
| 53 |
+
with tabs[1]:
|
| 54 |
monthly_income = st.number_input("Monthly Income", min_value=100, max_value=200000, value=10000)
|
| 55 |
+
own_car = st.radio("Owns a Car?", ["Yes", "No"], horizontal=True)
|
| 56 |
+
passport = st.radio("Has Passport?", ["Yes", "No"], horizontal=True)
|
| 57 |
|
| 58 |
+
with tabs[2]:
|
|
|
|
| 59 |
product_pitched = st.selectbox("Product Pitched", ["Deluxe", "Basic", "Standard", "Super Deluxe", "King"])
|
| 60 |
preferred_property_star = st.selectbox("Preferred Property Star", [3, 4, 5])
|
| 61 |
|
| 62 |
+
with tabs[3]:
|
|
|
|
| 63 |
num_person_visiting = st.number_input("Number of Persons Visiting", min_value=1, max_value=5, value=1)
|
| 64 |
num_children_visiting = st.number_input("Number of Children Visiting", min_value=0, max_value=3, value=0)
|
| 65 |
num_trips = st.number_input("Number of Trips", min_value=1, max_value=22, value=3)
|
| 66 |
|
| 67 |
+
with tabs[4]:
|
|
|
|
| 68 |
type_of_contact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
|
| 69 |
duration_of_pitch = st.number_input("Pitch Duration (minutes)", min_value=0, max_value=150, value=30)
|
| 70 |
num_followups = st.number_input("Number of Followups", min_value=1, max_value=6, value=1)
|
|
|
|
| 97 |
# ================================
|
| 98 |
# Prediction
|
| 99 |
# ================================
|
|
|
|
|
|
|
| 100 |
CLASSIFICATION_THRESHOLD = 0.45
|
| 101 |
|
| 102 |
+
if st.button("๐ฎ Predict", use_container_width=True):
|
| 103 |
+
proba = float(model.predict_proba(input_data)[0][1])
|
|
|
|
| 104 |
prediction = 1 if proba >= CLASSIFICATION_THRESHOLD else 0
|
| 105 |
|
| 106 |
result = "โ
Package Opted" if prediction == 1 else "โ Package Not Opted"
|
| 107 |
+
confidence = f"{proba * 100:.2f}"
|
| 108 |
|
| 109 |
+
st.markdown("---")
|
| 110 |
st.subheader("๐ Prediction Result")
|
| 111 |
st.success(f"**{result}** with {confidence}% confidence")
|
| 112 |
|