asvravi commited on
Commit
40a9bc1
·
verified ·
1 Parent(s): 6c60055

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -12
  2. app.py +249 -0
  3. requirements.txt +7 -3
Dockerfile CHANGED
@@ -1,20 +1,23 @@
1
- FROM python:3.13.5-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
 
14
  RUN pip3 install -r requirements.txt
15
 
16
- EXPOSE 8501
 
 
 
 
 
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
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
6
 
7
+ # Copy all files from the current directory on the host to the container's /app directory
8
+ COPY . .
 
 
 
 
 
 
9
 
10
+ # Install Python dependencies listed in requirements.txt
11
  RUN pip3 install -r requirements.txt
12
 
13
+ RUN useradd -m -u 1000 user
14
+ USER user
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
+
18
+ WORKDIR $HOME/app
19
 
20
+ COPY --chown=user . $HOME/app
21
 
22
+ # Define the command to run the Streamlit app on port "8501" and make it accessible externally
23
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
app.py ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from huggingface_hub import hf_hub_download
4
+ import joblib
5
+
6
+ # Download and load the model
7
+ model_path = hf_hub_download(repo_id="asvravi/asv-tourism-package", filename="best_toursim_package_model_v1.joblib")
8
+ model = joblib.load(model_path)
9
+
10
+ # Streamlit UI for Tourism Package Prediction
11
+ st.title("Tourism Package Prediction App")
12
+ st.write("""
13
+ This application predicts the likelihood of a customer buying the new Tourism Package.
14
+ Please enter the data below to get a prediction.
15
+ """)
16
+
17
+ # List of numerical features in the dataset
18
+ numeric_features = [
19
+ 'Age', # Customer's credit score
20
+ 'DurationOfPitch',
21
+ 'NumberOfFollowups',
22
+ 'PitchSatisfactionScore',
23
+ 'NumberOfPersonVisiting',
24
+ 'PreferredPropertyStar',
25
+ 'NumberOfTrips',
26
+ 'Passport',
27
+ 'OwnCar',
28
+ 'NumberOfChildrenVisiting',
29
+ 'MonthlyIncome',
30
+ 'CityTier', # City category based on development, population, and living standards
31
+ ]
32
+
33
+ # List of categorical features in the dataset
34
+ categorical_features = [
35
+ 'TypeofContact', # Country where the customer resides
36
+ 'Occupation', # Customer's occupation
37
+ 'Gender', # Gender of the customer
38
+ 'ProductPitched',
39
+ 'MaritalStatus', # Marital status of the customer
40
+ 'Designation', # Designation of the customer's current position
41
+ ]
42
+
43
+
44
+ # User input
45
+ st.header("Section 1 – Basic Information")
46
+
47
+ # ---------- Row 1 ----------
48
+ col1, col2, col3 = st.columns(3)
49
+
50
+ with col1:
51
+ age = st.number_input(
52
+ "Age",
53
+ min_value=1,
54
+ max_value=150,
55
+ value=25
56
+ )
57
+
58
+ with col2:
59
+ # Marital status alphabetically
60
+ marital_status_options = sorted(["Married", "Single", "Divorced", "Unmarried"])
61
+ marital_status = st.selectbox(
62
+ "Marital Status",
63
+ marital_status_options,
64
+ index=0
65
+ )
66
+
67
+ with col3:
68
+ gender = st.radio(
69
+ "Gender",
70
+ ["Male", "Female"],
71
+ index=0
72
+ )
73
+
74
+ # ---------- Row 2 ----------
75
+ col4, col5, col6 = st.columns(3)
76
+
77
+ with col4:
78
+ city_tier = st.selectbox(
79
+ "City Tier",
80
+ [1, 2, 3],
81
+ index=0
82
+ )
83
+
84
+ with col5:
85
+ total_family = st.number_input(
86
+ "Total Family Members",
87
+ min_value=1,
88
+ max_value=50,
89
+ value=1,
90
+ step=1
91
+ )
92
+
93
+ with col6:
94
+ children = st.number_input(
95
+ "No. of Children (age > 5)",
96
+ min_value=0,
97
+ max_value=20,
98
+ value=0,
99
+ step=1
100
+ )
101
+
102
+ # ---------- Row 3 ----------
103
+ col7, col8, col9 = st.columns(3)
104
+
105
+ with col7:
106
+ own_car = st.selectbox(
107
+ "Own a Car",
108
+ ["Yes", "No"],
109
+ index=0
110
+ )
111
+
112
+ st.header("Section 2 – Professional Details")
113
+
114
+ # ---------- Row 1 ----------
115
+ col1, col2, col3 = st.columns(3)
116
+
117
+ with col1:
118
+ occupation_options = sorted(["Free Lancer", "Salaried", "Large Business", "Small Business"])
119
+ occupation = st.selectbox(
120
+ "Occupation",
121
+ occupation_options,
122
+ index=0
123
+ )
124
+
125
+ with col2:
126
+ designation_options = sorted(["AVP", "Manager", "Senior Manager", "Executive", "VP"])
127
+ designation = st.selectbox(
128
+ "Designation",
129
+ designation_options,
130
+ index=0
131
+ )
132
+
133
+ with col3:
134
+ monthly_salary = st.number_input(
135
+ "Monthly Salary",
136
+ min_value=1000,
137
+ max_value=100000,
138
+ value=1000,
139
+ step=100
140
+ )
141
+
142
+
143
+ st.header("Section 3 – Travel Preferences")
144
+
145
+ # ---------- Row 1 ----------
146
+ col1, col2, col3 = st.columns(3)
147
+
148
+ with col1:
149
+ property_star = st.selectbox(
150
+ "Preferred Property Star",
151
+ [3, 4, 5],
152
+ index=0
153
+ )
154
+
155
+ with col2:
156
+ trips_per_year = st.number_input(
157
+ "Number of Trips per Year",
158
+ min_value=1,
159
+ max_value=50,
160
+ value=1,
161
+ step=1
162
+ )
163
+
164
+ with col3:
165
+ passport = st.selectbox(
166
+ "Passport",
167
+ ["Yes", "No"],
168
+ index=0
169
+ )
170
+
171
+ st.header("Section 4 – Sales Interaction Details")
172
+
173
+ # ---------- Row 1 ----------
174
+ col1, col2, col3 = st.columns(3)
175
+
176
+ with col1:
177
+ type_of_contact = st.selectbox(
178
+ "Type of Contact",
179
+ ["Company Invited", "Self Enquiry"],
180
+ index=0
181
+ )
182
+
183
+ with col2:
184
+ product_pitched = st.selectbox(
185
+ "Product Pitched",
186
+ ["Basic", "Deluxe", "King", "Standard", "Super Deluxe"],
187
+ index=0
188
+ )
189
+
190
+ with col3:
191
+ pitch_duration = st.number_input(
192
+ "Duration of Pitch (minutes)",
193
+ min_value=1,
194
+ max_value=150,
195
+ value=1,
196
+ step=1
197
+ )
198
+
199
+ # ---------- Row 2 ----------
200
+ col4, col5, col6 = st.columns(3)
201
+
202
+ with col4:
203
+ followups = st.number_input(
204
+ "Number of Follow-ups",
205
+ min_value=1,
206
+ max_value=10,
207
+ value=1,
208
+ step=1
209
+ )
210
+
211
+ with col5:
212
+ pitch_satisfaction = st.selectbox(
213
+ "Pitch Satisfaction Score",
214
+ [1, 2, 3, 4, 5],
215
+ index=0
216
+ )
217
+
218
+
219
+ own_car = 1 if own_car == "Yes" else 0
220
+ passport = 1 if passport == "Yes" else 0
221
+
222
+ # Assemble input into DataFrame
223
+ input_data = pd.DataFrame([{
224
+ 'Age': age,
225
+ 'DurationOfPitch': pitch_duration,
226
+ 'NumberOfFollowups': followups,
227
+ 'PitchSatisfactionScore': pitch_satisfaction,
228
+ 'NumberOfPersonVisiting': total_family,
229
+ 'PreferredPropertyStar': property_star,
230
+ 'NumberOfTrips': trips_per_year,
231
+ 'Passport': passport,
232
+ 'OwnCar': own_car,
233
+ 'NumberOfChildrenVisiting': children,
234
+ 'MonthlyIncome': monthly_salary,
235
+ 'CityTier': city_tier,
236
+ 'TypeofContact': type_of_contact,
237
+ 'Occupation': occupation,
238
+ 'Gender': gender,
239
+ 'ProductPitched': product_pitched,
240
+ 'MaritalStatus': marital_status,
241
+ 'Designation': designation
242
+ }])
243
+
244
+ # Predict button
245
+ if st.button("Predict"):
246
+ prediction_proba = model.predict_proba(input_data)[0, 1]
247
+ prediction = (prediction_proba >= classification_threshold).astype(int)
248
+ result = "likely to buy" if prediction == 1 else "not likely to buy"
249
+ st.write(f"Based on the information provided, the customer is {result} the new tourism package.")
requirements.txt CHANGED
@@ -1,3 +1,7 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
1
+ pandas==2.2.2
2
+ huggingface_hub==0.32.6
3
+ streamlit==1.43.2
4
+ joblib==1.5.1
5
+ scikit-learn==1.6.0
6
+ xgboost==2.1.4
7
+ mlflow==3.0.1