subhash33 commited on
Commit
0a375a0
·
verified ·
1 Parent(s): 5474c4e

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -12
  2. app.py +69 -0
  3. requirements.txt +8 -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
 
2
+ # Use a minimal base image with Python 3.9 installed
3
+ FROM python:3.9
4
 
5
+ # Set the working directory inside the container to /app
6
+ WORKDIR /app
 
 
 
7
 
8
+ # Copy all files from the current directory on the host to the container's /app directory
9
+ COPY . .
10
 
11
+ # Install Python dependencies listed in requirements.txt
12
  RUN pip3 install -r requirements.txt
13
 
14
+ RUN useradd -m -u 1000 user
15
+ USER user
16
+ ENV HOME=/home/user \
17
+ PATH=/home/user/.local/bin:$PATH
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,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ from huggingface_hub import hf_hub_download
5
+ import joblib
6
+
7
+ # Download the model from the Model Hub
8
+ model_path = hf_hub_download(repo_id="subhash33/Tourism-Package-Model", filename="best_tourism_model.joblib")
9
+
10
+ # Load the model
11
+ model = joblib.load(model_path)
12
+
13
+ # Streamlit UI for Tourism Package Prediction
14
+ st.title("Tourism Package Prediction App")
15
+ st.write("The Tourism Package Prediction App whether a customer will purchase the newly introduced Wellness Tourism Package before contacting them based on their details.")
16
+ st.write("Kindly enter the customer details to check whether they are likely to purchase the new package.")
17
+
18
+ # Collect user input
19
+ Age = st.number_input("Age", min_value=18, max_value=100, value=20)
20
+ TypeofContact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
21
+ CityTier = st.selectbox("City Tier", [1, 2, 3])
22
+ DurationOfPitch = st.number_input("Duration of Pitch", min_value=1, max_value=150, value=15)
23
+ Occupation = st.selectbox("Occupation", ["Salaried", "Small Business", "Large Business", "Free Lancer"])
24
+ Gender = st.selectbox("Gender", ["Male", "Female"])
25
+ NumberOfPersonVisiting = st.number_input("Number of People Visiting", min_value=1, max_value=10, value=3)
26
+ NumberOfFollowups = st.number_input("Number of Follow-ups", min_value=0, max_value=10, value=3)
27
+ ProductPitched = st.selectbox("Product Pitched", ["Basic", "Standard", "Deluxe", "Super Deluxe", "King"])
28
+ PreferredPropertyStar = st.selectbox("Preferred Property Star", [3, 4, 5])
29
+ MaritalStatus = st.selectbox("Marital Status", ["Married", "Unmarried", "Divorced", "Single"])
30
+ NumberOfTrips = st.number_input("Number of Trips", min_value=1, max_value=50, value=3)
31
+ Passport = st.selectbox("Passport", ["Yes", "No"])
32
+ PitchSatisfactionScore = st.selectbox("Pitch Satisfaction Score", [1, 2, 3, 4, 5])
33
+ OwnCar = st.selectbox("Own Car", ["Yes", "No"])
34
+ NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, max_value=10, value=2)
35
+ Designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP", "VP"])
36
+ MonthlyIncome = st.number_input("Monthly Income", min_value=0, max_value=100000, value=25000)
37
+
38
+
39
+ # Convert categorical inputs to match model training
40
+ input_data = pd.DataFrame([{
41
+ 'Age': Age,
42
+ 'TypeofContact': TypeofContact,
43
+ 'CityTier': CityTier,
44
+ 'DurationOfPitch': DurationOfPitch,
45
+ 'Occupation': Occupation,
46
+ 'Gender': Gender,
47
+ 'NumberOfPersonVisiting': NumberOfPersonVisiting,
48
+ 'NumberOfFollowups': NumberOfFollowups,
49
+ 'ProductPitched': ProductPitched,
50
+ 'PreferredPropertyStar': PreferredPropertyStar,
51
+ 'MaritalStatus': MaritalStatus,
52
+ 'NumberOfTrips': NumberOfTrips,
53
+ 'Passport': 1 if Passport == "Yes" else 0,
54
+ 'PitchSatisfactionScore': PitchSatisfactionScore,
55
+ 'OwnCar': 1 if OwnCar == "Yes" else 0,
56
+ 'NumberOfChildrenVisiting': NumberOfChildrenVisiting,
57
+ 'Designation': Designation,
58
+ 'MonthlyIncome': MonthlyIncome
59
+ }])
60
+
61
+ # Set the classification threshold
62
+ classification_threshold = 0.45
63
+
64
+ # Predict Button
65
+ if st.button("predict"):
66
+ predict_proba = model.predict_proba(input_data)[0, 1]
67
+ prediction = (predict_proba >= classification_threshold).astype(int)
68
+ result = "Purchase the Package" if prediction == 1 else "Not likely to purchase the package"
69
+ st.write(f"Based on the information provided, the customer is likely to {result}.")
requirements.txt CHANGED
@@ -1,3 +1,8 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
 
1
+
2
+ pandas==2.2.2
3
+ huggingface_hub==0.32.6
4
+ streamlit==1.43.2
5
+ joblib==1.5.1
6
+ # scikit-learn==1.6.0
7
+ # xgboost==2.1.4
8
+ # mlflow==3.0.1