viveksardey commited on
Commit
6f5b8e0
·
verified ·
1 Parent(s): 651ac4f

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -12
  2. app.py +110 -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=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
app.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from huggingface_hub import hf_hub_download
4
+ import joblib
5
+
6
+ # -------------------------------
7
+ # LOAD MODEL FROM HUGGING FACE HUB
8
+ # -------------------------------
9
+ model_path = hf_hub_download(
10
+ repo_id="viveksardey/tourism-package-prediction-model",
11
+ filename="tourism-package-prediction_model.joblib"
12
+ )
13
+ model = joblib.load(model_path)
14
+
15
+ # -------------------------------
16
+ # STREAMLIT APP
17
+ # -------------------------------
18
+ st.title("Tourism Package Purchase Prediction App")
19
+
20
+ st.write("""
21
+ This application predicts whether a customer is likely to purchase the **Tourism Package**
22
+ offered by *Visit with Us*.
23
+
24
+ Please enter the customer details below to get the prediction.
25
+ """)
26
+
27
+ # -------------------------------
28
+ # USER INPUT FIELDS
29
+ # -------------------------------
30
+ Age = st.number_input("Customer Age", min_value=0, max_value=100, value=30)
31
+
32
+ Gender = st.selectbox("Gender", ["Male", "Female"])
33
+
34
+ TypeofContact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"])
35
+
36
+ CityTier = st.selectbox("City Tier", [1, 2, 3])
37
+
38
+ Occupation = st.selectbox(
39
+ "Occupation",
40
+ ["Salaried", "Self Employed", "Freelancer", "Company Owner", "Other"]
41
+ )
42
+
43
+ MaritalStatus = st.selectbox(
44
+ "Marital Status",
45
+ ["Single", "Married", "Divorced"]
46
+ )
47
+
48
+ ProductPitched = st.selectbox(
49
+ "Product Pitched",
50
+ ["Basic", "Deluxe", "Standard", "King", "Super Deluxe"]
51
+ )
52
+
53
+ Designation = st.selectbox(
54
+ "Designation",
55
+ ["Manager", "Executive", "Senior Manager", "AVP", "VP"]
56
+ )
57
+
58
+ MonthlyIncome = st.number_input("Monthly Income", min_value=0, value=50000)
59
+
60
+ NumberOfTrips = st.number_input("Average Trips per Year", min_value=0, value=1)
61
+
62
+ NumberOfPersonVisiting = st.number_input("Number of Persons Visiting", min_value=1, value=2)
63
+
64
+ PreferredPropertyStar = st.selectbox("Preferred Hotel Star Rating", [1, 2, 3, 4, 5])
65
+
66
+ NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, value=0)
67
+
68
+ Passport = st.selectbox("Passport Available?", [0, 1])
69
+
70
+ OwnCar = st.selectbox("Owns a Car?", [0, 1])
71
+
72
+ PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3)
73
+
74
+ NumberOfFollowups = st.number_input("Number of Follow-ups", min_value=0, value=2)
75
+
76
+ DurationOfPitch = st.number_input("Duration of Pitch (minutes)", min_value=0, value=15)
77
+
78
+ # -------------------------------
79
+ # CREATE INPUT DATAFRAME
80
+ # -------------------------------
81
+ input_data = pd.DataFrame([{
82
+ "Age": Age,
83
+ "Gender": Gender,
84
+ "TypeofContact": TypeofContact,
85
+ "CityTier": CityTier,
86
+ "Occupation": Occupation,
87
+ "MaritalStatus": MaritalStatus,
88
+ "NumberOfPersonVisiting": NumberOfPersonVisiting,
89
+ "PreferredPropertyStar": PreferredPropertyStar,
90
+ "NumberOfTrips": NumberOfTrips,
91
+ "Passport": Passport,
92
+ "OwnCar": OwnCar,
93
+ "NumberOfChildrenVisiting": NumberOfChildrenVisiting,
94
+ "Designation": Designation,
95
+ "MonthlyIncome": MonthlyIncome,
96
+ "PitchSatisfactionScore": PitchSatisfactionScore,
97
+ "ProductPitched": ProductPitched,
98
+ "NumberOfFollowups": NumberOfFollowups,
99
+ "DurationOfPitch": DurationOfPitch
100
+ }])
101
+
102
+ # -------------------------------
103
+ # PREDICTION
104
+ # -------------------------------
105
+ if st.button("Predict Purchase Likelihood"):
106
+ prediction = model.predict(input_data)[0]
107
+ result = "Will Purchase Package" if prediction == 1 else "Will Not Purchase Package"
108
+
109
+ st.subheader("Prediction Result:")
110
+ st.success(f"The model predicts: **{result}**")
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