Pushpak21 commited on
Commit
4b5269e
·
verified ·
1 Parent(s): 791f6fb

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -11
  2. app.py +84 -0
  3. requirements.txt +7 -3
Dockerfile CHANGED
@@ -1,20 +1,24 @@
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
+ USER user
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
 
14
+ # Install Python dependencies listed in requirements.txt
15
  RUN pip3 install -r requirements.txt
16
 
17
+ RUN useradd -m -u 1000 user
18
 
19
+ WORKDIR $HOME/app
20
 
21
+ COPY --chown=user . $HOME/app
22
+
23
+ # Define the command to run the Streamlit app on port "8501" and make it accessible externally
24
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import joblib
5
+
6
+
7
+ # Download and load the model
8
+ model_path = hf_hub_download(repo_id="Pushpak21/tourism-package-model", filename="best_tourism_package_model.joblib")
9
+ model = joblib.load(model_path)
10
+
11
+ # Feature descriptions
12
+ feature_info = {
13
+ "Age": "Age of the customer (years).",
14
+ "TypeofContact": "How the customer was contacted (Company Invited / Self Inquiry).",
15
+ "CityTier": "City category (1=Tier1, 2=Tier2, 3=Tier3).",
16
+ "Occupation": "Customer occupation (Salaried, Freelancer, etc.).",
17
+ "Gender": "Male or Female.",
18
+ "NumberOfPersonVisiting": "Total number of people visiting together.",
19
+ "PreferredPropertyStar": "Preferred hotel star rating (3,4,5).",
20
+ "MaritalStatus": "Single / Married / Divorced.",
21
+ "NumberOfTrips": "Average trips per year.",
22
+ "Passport": "Has passport? (0 = No, 1 = Yes).",
23
+ "OwnCar": "Owns car? (0 = No, 1 = Yes).",
24
+ "NumberOfChildrenVisiting": "Children under 5 accompanying.",
25
+ "Designation": "Job designation/title.",
26
+ "MonthlyIncome": "Gross monthly income.",
27
+ "PitchSatisfactionScore": "Satisfaction score for the sales pitch (1-5).",
28
+ "ProductPitched": "Product variant pitched to the customer.",
29
+ "NumberOfFollowups": "Number of follow-ups by salesperson.",
30
+ "DurationOfPitch": "Duration of pitch in minutes."
31
+ }
32
+
33
+ st.sidebar.title("Feature descriptions")
34
+ for k, v in feature_info.items():
35
+ st.sidebar.write(f"**{k}** — {v}")
36
+
37
+ # Example form using help text (tooltips)
38
+ with st.form("input_form"):
39
+ age = st.number_input("Age", min_value=18, max_value=100, value=30, help=feature_info["Age"])
40
+ typeof_contact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"], help=feature_info["TypeofContact"])
41
+ city_tier = st.selectbox("City Tier", [1,2,3], help=feature_info["CityTier"])
42
+ occupation = st.selectbox("Occupation", ["Salaried", "Free Lancer", "Small Business", "Large Business"], help=feature_info["Occupation"])
43
+ gender = st.selectbox("Gender", ["Male", "Female"], help=feature_info["Gender"])
44
+ persons = st.number_input("Number Of Person Visiting", min_value=1, max_value=5, value=2, help=feature_info["NumberOfPersonVisiting"])
45
+ star = st.selectbox("Preferred Property Star", [3,4,5], help=feature_info["PreferredPropertyStar"])
46
+ marital = st.selectbox("Marital Status", ["Single", "Married", "Divorced","Unmarried"], help=feature_info["MaritalStatus"])
47
+ trips = st.number_input("Number Of Trips", min_value=1, max_value=25, value=2, help=feature_info["NumberOfTrips"])
48
+ passport = st.radio("Passport", [0,1], help=feature_info["Passport"])
49
+ owncar = st.radio("Own Car", [0,1], help=feature_info["OwnCar"])
50
+ children = st.number_input("Number Of Children Visiting", min_value=0, max_value=3, value=0, help=feature_info["NumberOfChildrenVisiting"])
51
+ designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP","VP"], help=feature_info["Designation"])
52
+ income = st.number_input("Monthly Income", min_value=1000, max_value=100000, value=30000, help=feature_info["MonthlyIncome"])
53
+ satisfaction = st.slider("Pitch Satisfaction Score", min_value=1, max_value=5, value=3, help=feature_info["PitchSatisfactionScore"])
54
+ product = st.selectbox("Product Pitched", ["Basic", "Standard","King", "Deluxe", "Super Deluxe"], help=feature_info["ProductPitched"])
55
+ followups = st.number_input("Number Of Followups", min_value=1, max_value=6, value=2, help=feature_info["NumberOfFollowups"])
56
+ duration = st.number_input("Duration Of Pitch (minutes)", min_value=0, max_value=300, value=10, help=feature_info["DurationOfPitch"])
57
+
58
+ submitted = st.form_submit_button("Predict")
59
+
60
+ if submitted:
61
+ input_df = pd.DataFrame([{
62
+ "Age": age,
63
+ "TypeofContact": typeof_contact,
64
+ "CityTier": city_tier,
65
+ "Occupation": occupation,
66
+ "Gender": gender,
67
+ "NumberOfPersonVisiting": persons,
68
+ "PreferredPropertyStar": star,
69
+ "MaritalStatus": marital,
70
+ "NumberOfTrips": trips,
71
+ "Passport": passport,
72
+ "OwnCar": owncar,
73
+ "NumberOfChildrenVisiting": children,
74
+ "Designation": designation,
75
+ "MonthlyIncome": income,
76
+ "PitchSatisfactionScore": satisfaction,
77
+ "ProductPitched": product,
78
+ "NumberOfFollowups": followups,
79
+ "DurationOfPitch": duration
80
+ }])
81
+ proba = model.predict_proba(input_df)[0,1]
82
+ pred = model.predict(input_df)[0]
83
+ st.write("Probability:", round(proba,3))
84
+ st.write("Prediction:", "Will buy (1)" if pred==1 else "Will not buy (0)")
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