sumansaha1980 commited on
Commit
381ccbc
·
verified ·
1 Parent(s): 562d20a

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -12
  2. app.py +89 -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,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="sumansaha1980/Tourism_Package", filename="best_wellness_tourism_model_v1.joblib")
8
+ model = joblib.load(model_path)
9
+
10
+ # ------------------------------
11
+ # Streamlit UI
12
+ # ------------------------------
13
+ st.title("Wellness Tourism Prediction App")
14
+
15
+ st.write("""
16
+ This application predicts potential buyers of Wellness Tourism Package based on customer data.
17
+ Please enter **Customer Data** and **Customer Interaction Data** below to get a prediction.
18
+ """)
19
+
20
+ # ------------------------------
21
+ # User Inputs
22
+ # ------------------------------
23
+ st.subheader("Customer Details")
24
+
25
+ CustomerID = st.text_input("CustomerID (Unique ID)", value="12345") # Not used in model but for reference
26
+ Age = st.number_input("Age", min_value=0, max_value=120, value=35)
27
+ TypeofContact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"])
28
+ CityTier = st.selectbox("City Tier", [1, 2, 3])
29
+ Occupation = st.selectbox("Occupation", ["Salaried", "Small Business", "Large Business", "Free Lancer", "Others"])
30
+ Gender = st.radio("Gender", ["Male", "Female", "Other"])
31
+ NumberOfPersonVisiting = st.number_input("Number of Persons Visiting", min_value=1, value=2)
32
+ PreferredPropertyStar = st.selectbox("Preferred Property Star", [1, 2, 3, 4, 5])
33
+ MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced", "Unmarried"])
34
+ NumberOfTrips = st.number_input("Average Number of Trips per year", min_value=0, value=2)
35
+ Passport = st.radio("Has Passport?", [0, 1])
36
+ OwnCar = st.radio("Owns a Car?", [0, 1])
37
+ NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, value=0)
38
+ Designation = st.text_input("Designation", value="Manager")
39
+ MonthlyIncome = st.number_input("Monthly Income", min_value=0, value=50000)
40
+
41
+ st.subheader("Customer Interaction Data")
42
+
43
+ PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", min_value=1, max_value=5, value=3)
44
+ ProductPitched = st.selectbox("Product Pitched", ["Basic", "Deluxe", "Standard", "Super Deluxe", "King"])
45
+ NumberOfFollowups = st.number_input("Number of Followups", min_value=0, value=2)
46
+ DurationOfPitch = st.number_input("Duration of Pitch (minutes)", min_value=0, value=20)
47
+
48
+ # ------------------------------
49
+ # Prepare Input for Prediction
50
+ # ------------------------------
51
+ input_data = {
52
+ "Age": Age,
53
+ "TypeofContact": TypeofContact,
54
+ "CityTier": CityTier,
55
+ "Occupation": Occupation,
56
+ "Gender": Gender,
57
+ "NumberOfPersonVisiting": NumberOfPersonVisiting,
58
+ "PreferredPropertyStar": PreferredPropertyStar,
59
+ "MaritalStatus": MaritalStatus,
60
+ "NumberOfTrips": NumberOfTrips,
61
+ "Passport": Passport,
62
+ "OwnCar": OwnCar,
63
+ "NumberOfChildrenVisiting": NumberOfChildrenVisiting,
64
+ "Designation": Designation,
65
+ "MonthlyIncome": MonthlyIncome,
66
+ "PitchSatisfactionScore": PitchSatisfactionScore,
67
+ "ProductPitched": ProductPitched,
68
+ "NumberOfFollowups": NumberOfFollowups,
69
+ "DurationOfPitch": DurationOfPitch
70
+ }
71
+
72
+ input_df = pd.DataFrame([input_data])
73
+
74
+ # ------------------------------
75
+ # Prediction
76
+ # ------------------------------
77
+ if st.button("Predict"):
78
+ prediction = model.predict(input_df)[0]
79
+ probability = model.predict_proba(input_df)[0][1]
80
+
81
+ # Use custom threshold as dataset is imbalanced on target column
82
+ # where only 19% has taken the product
83
+ classification_threshold = 0.45
84
+ prediction = (probability >= classification_threshold).astype(int)
85
+
86
+ if prediction == 1:
87
+ st.success(f"✅ This customer is **likely to purchase** the Wellness Tourism Package. (Confidence: {probability:.2f})")
88
+ else:
89
+ st.error(f"❌ This customer is **unlikely to purchase** the package. (Confidence: {probability:.2f})")
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