Parthi07 commited on
Commit
a8ed6a3
ยท
verified ยท
1 Parent(s): ba03cc3

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. 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.write(
13
  """
14
- This application predicts whether a customer is likely to **opt for a tourism package**
15
- based on their profile and preferences.
16
- Please provide the customer details below:
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
- # Sidebar Input Form (Improved Layout)
37
  # ================================
38
- st.sidebar.header("๐Ÿ“ Enter Customer Details")
39
-
40
- # --------- 1. Personal Information ---------
41
- with st.sidebar.expander("๐Ÿ‘ค Personal Information", expanded=True):
 
 
 
 
 
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
- # --------- 2. Lifestyle & Financial ---------
49
- with st.sidebar.expander("๐Ÿ’ฐ Lifestyle & Financial", expanded=True):
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
- # --------- 3. Travel Preferences ---------
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
- # --------- 4. Trip & Family Details ---------
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
- # --------- 5. Sales Interaction ---------
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
- # Get probability of "Product Taken" (class = 1)
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 = round(proba * 100, 2)
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