anithajk commited on
Commit
9de45f2
·
verified ·
1 Parent(s): e098f63

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. Dockerfile +15 -12
  2. app.py +97 -0
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,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="anithajk/tourism_model", filename="best_tourism_model.joblib")
8
+
9
+ # Load the model
10
+ model = joblib.load(model_path)
11
+ # Streamlit UI for Tourism Package Purchase Prediction
12
+ st.title("Tourism Package Purchase Prediction App")
13
+ st.write("Fill the details below to predict whether the customer will purchase the package.")
14
+
15
+ # Collect user input
16
+ # -------------------------------------------------------
17
+ # USER INPUT SECTION
18
+ # -------------------------------------------------------
19
+
20
+ Age = st.number_input(
21
+ "Age (Customer's age in years)",
22
+ min_value=18, max_value=80, value=30
23
+ )
24
+
25
+ DurationOfPitch = st.number_input(
26
+ "Duration Of Pitch (minutes)",
27
+ min_value=0, max_value=120, value=15
28
+ )
29
+
30
+ NumberOfFollowups = st.number_input(
31
+ "Number of Follow-ups",
32
+ min_value=0, max_value=10, value=2
33
+ )
34
+
35
+ MonthlyIncome = st.number_input(
36
+ "Monthly Income",
37
+ min_value=1000, max_value=300000, value=50000
38
+ )
39
+
40
+ NumberOfChildrenVisiting = st.number_input(
41
+ "Number Of Children Visiting",
42
+ min_value=0, max_value=5, value=1
43
+ )
44
+
45
+ Passport = st.selectbox("Passport (Does customer have a passport?)", ["Yes", "No"])
46
+ OwnCar = st.selectbox("Own Car (Does customer own a car?)", ["Yes", "No"])
47
+
48
+ TypeofContact = st.selectbox(
49
+ "Type of Contact",
50
+ ["Self Enquiry", "Company Invited"]
51
+ )
52
+
53
+ Occupation = st.selectbox(
54
+ "Occupation",
55
+ ["Salaried", "Small Business", "Large Business", "Student", "Free Lancer"]
56
+ )
57
+
58
+ Gender = st.selectbox(
59
+ "Gender",
60
+ ["Male", "Female"]
61
+ )
62
+
63
+ Designation = st.selectbox(
64
+ "Designation",
65
+ ["Executive", "Manager", "Senior Manager", "AVP", "VP"]
66
+ )
67
+
68
+
69
+ # Convert categorical inputs to match model training
70
+ # -------------------------------------------------------
71
+ # 2. CREATE INPUT DATAFRAME
72
+ # -------------------------------------------------------
73
+ input_data = pd.DataFrame({
74
+ "Age": [Age],
75
+ "DurationOfPitch": [DurationOfPitch],
76
+ "NumberOfFollowups": [NumberOfFollowups],
77
+ "MonthlyIncome": [MonthlyIncome],
78
+ "NumberOfChildrenVisiting": [NumberOfChildrenVisiting],
79
+ "Passport": [1 if Passport == "Yes" else 0],
80
+ "OwnCar": [1 if OwnCar == "Yes" else 0],
81
+ "TypeofContact": [TypeofContact],
82
+ "Occupation": [Occupation],
83
+ "Gender": [Gender],
84
+ "Designation": [Designation]
85
+ })
86
+
87
+ st.write("### Input Summary")
88
+ st.dataframe(input_data)
89
+
90
+ # Predict button
91
+ if st.button("Predict"):
92
+ prediction = model.predict(input_data)[0]
93
+
94
+ if prediction == 1:
95
+ st.success("The customer is **LIKELY** to purchase the tourism package!")
96
+ else:
97
+ st.warning("The customer is **NOT likely** to purchase the package.")