rishabhsinghjk commited on
Commit
fd158ac
·
verified ·
1 Parent(s): dee8572

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -12
  2. app.py +69 -0
  3. requirements.txt +8 -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 "8500" and make it accessible externally
23
+ CMD ["streamlit", "run", "app.py", "--server.port=8500", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from huggingface_hub import hf_hub_download
4
+ import joblib
5
+
6
+ # Download the model from the Model Hub
7
+ model_path = hf_hub_download(repo_id="rishabhsinghjk/Tourism-package-predict-model", filename="best_tour_pkg_predct_v1.joblib")
8
+
9
+ # Load the model
10
+ model = joblib.load(model_path)
11
+
12
+ # Streamlit UI for Customer Churn Prediction
13
+ st.title("Tourism package Customer Acceptance Prediction App")
14
+ st.write("The Tourism package Customer Acceptance Prediction App is an internal tool for tourism comapny employees to predicts whether customers will accept the pitched package based on their details.")
15
+ st.write("Kindly enter the customer details to check whether they are likely to accept.")
16
+
17
+ # Collect user input
18
+ DurationOfPitch = st.number_input("Duration Of Pitch (Time duration in minutes)", min_value=1.0, max_value=100.0, value=1.0)
19
+ TypeofContact = st.selectbox("Type of Contact (Method by which the customer was contacted)", ["Self Enquiry", "Company Invited"])
20
+ Age = st.number_input("Age (customer's age in years)", min_value=18, max_value=100, value=25)
21
+ NumberOfPersonVisiting = st.number_input("Number Of Person Visiting",min_value=1, value=2)
22
+ NumberOfFollowups = st.number_input("Number Of Followups (Follow-ups done with the customer)", min_value=0.0, value=1.0)
23
+ NumberOfTrips = st.number_input("Number Of Trips (Number of trips the customer takes annually.)", min_value=0.0, value=1.0)
24
+ NumberOfChildrenVisiting = st.number_input("Number Of Children Visiting", min_value=0, value=0)
25
+ MonthlyIncome = st.number_input("Monthly Income of customer", min_value=100.0, value=10000.0)
26
+ CityTier = st.selectbox("City Tier of customer", ["1", "2", "3"])
27
+ Occupation = st.selectbox("Occupation of customer", ["Salaried", "Small Business", "Large Business", "Free Lancer"])
28
+ Gender = st.selectbox("Gender", ["Male", "Female"])
29
+ ProductPitched = st.selectbox("Product category Pitched to customer", ["Basic", "Deluxe", "Standard", "Super Deluxe", "King"])
30
+ PreferredPropertyStar = st.selectbox("Preferred Property Star", ["1", "2", "3", "4", "5"])
31
+ MaritalStatus = st.selectbox("Marital Status", ["Married", "Single", "Divorced", "Unmarried"])
32
+ Passport = st.selectbox("Has Passport?", ["Yes", "No"])
33
+ PitchSatisfactionScore = st.selectbox("Pitch Satisfaction Score by customer", ["5", "4", "3", "2", "1"])
34
+ OwnCar = st.selectbox("Customer owns Car?", ["Yes", "No"])
35
+ Designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP", "VP"])
36
+
37
+
38
+
39
+ # Convert categorical inputs to match model training
40
+ input_data = pd.DataFrame([{
41
+ 'DurationOfPitch': DurationOfPitch,
42
+ 'TypeofContact': TypeofContact,
43
+ 'Age': Age,
44
+ 'NumberOfPersonVisiting': NumberOfPersonVisiting,
45
+ 'NumberOfFollowups': NumberOfFollowups,
46
+ 'NumberOfTrips': NumberOfTrips,
47
+ 'NumberOfChildrenVisiting': NumberOfChildrenVisiting,
48
+ 'MonthlyIncome': MonthlyIncome,
49
+ 'CityTier': CityTier,
50
+ 'Occupation': Occupation,
51
+ 'Gender': Gender,
52
+ 'ProductPitched': ProductPitched,
53
+ 'PreferredPropertyStar': PreferredPropertyStar,
54
+ 'MaritalStatus': MaritalStatus,
55
+ 'Passport': 1 if Passport == "Yes" else 0,
56
+ 'PitchSatisfactionScore': PitchSatisfactionScore,
57
+ 'OwnCar': 1 if OwnCar == "Yes" else 0,
58
+ 'Designation': Designation
59
+ }])
60
+
61
+ # Set the classification threshold
62
+ classification_threshold = 0.45
63
+
64
+ # Predict button
65
+ if st.button("Predict"):
66
+ prediction_proba = model.predict_proba(input_data)[0, 1]
67
+ prediction = (prediction_proba >= classification_threshold).astype(int)
68
+ result = "accept" if prediction == 1 else "not accept"
69
+ st.write(f"Based on the information provided, the customer is likely to {result} package.")
requirements.txt CHANGED
@@ -1,3 +1,8 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
 
1
+ pandas==2.2.2
2
+ numpy==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==3.0.4
8
+ mlflow==3.3.1