Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +60 -0
- requirements.txt +7 -3
Dockerfile
CHANGED
|
@@ -1,20 +1,23 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
| 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,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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="papsofts/tourism-project", filename="best_tourism_model_v1.joblib")
|
| 9 |
+
|
| 10 |
+
# Load the model
|
| 11 |
+
model = joblib.load(model_path)
|
| 12 |
+
|
| 13 |
+
# Streamlit UI for Customer Churn Prediction
|
| 14 |
+
st.title("Wellness Tourism Package Prediction App")
|
| 15 |
+
st.write("The Wellness Tourism Package Prediction App is an internal tool for the tourism staff that predicts whether customers who might choose the wellness tour package based on their details.")
|
| 16 |
+
st.write("Kindly enter the customer details to check whether they are likely to choose the wellness tourism package.")
|
| 17 |
+
|
| 18 |
+
# Collect user input
|
| 19 |
+
Age = st.number_input("Age (customer's age in years)", min_value=18, max_value=100, value=30)
|
| 20 |
+
TypeofContact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"])
|
| 21 |
+
CityTier = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
|
| 22 |
+
Occupation = st.selectbox("Occupation", ["Salaried", "Freelancer"])
|
| 23 |
+
Gender = st.selectbox("Gender", ["Male", "Female"])
|
| 24 |
+
NumberOfPersonVisiting = st.number_input("Number of People Visiting", min_value=1, max_value=10, value=2)
|
| 25 |
+
PreferredPropertyStar = st.number_input("Preferred Property Star", min_value=1, max_value=5, value=4)
|
| 26 |
+
MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
|
| 27 |
+
NumberOfTrips = st.number_input("Number of Trips", min_value=1, max_value=10, value=2)
|
| 28 |
+
Passport = st.selectbox("Passport", ["No", "Yes"])
|
| 29 |
+
OwnCar = st.selectbox("Own Car", ["No", "Yes"])
|
| 30 |
+
NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, max_value=5, value=0)
|
| 31 |
+
Designation = st.selectbox("Designation", ["Executive", "Managerial", "Professional", "Other"])
|
| 32 |
+
MonthlyIncome = st.number_input("Monthly Income", min_value=0, value=5000)
|
| 33 |
+
|
| 34 |
+
# Convert categorical inputs to match model training
|
| 35 |
+
input_data = pd.DataFrame([{
|
| 36 |
+
'Age': Age,
|
| 37 |
+
'TypeofContact': TypeofContact,
|
| 38 |
+
'CityTier': CityTier,
|
| 39 |
+
'Occupation': Occupation,
|
| 40 |
+
'Gender': Gender,
|
| 41 |
+
'NumberOfPersonVisiting': NumberOfPersonVisiting,
|
| 42 |
+
'PreferredPropertyStar': PreferredPropertyStar,
|
| 43 |
+
'MaritalStatus': MaritalStatus,
|
| 44 |
+
'NumberOfTrips': NumberOfTrips,
|
| 45 |
+
'Passport': Passport,
|
| 46 |
+
'OwnCar': OwnCar,
|
| 47 |
+
'NumberOfChildrenVisiting': NumberOfChildrenVisiting,
|
| 48 |
+
'Designation': Designation,
|
| 49 |
+
'MonthlyIncome': MonthlyIncome
|
| 50 |
+
}])
|
| 51 |
+
|
| 52 |
+
# Set the classification threshold
|
| 53 |
+
classification_threshold = 0.45
|
| 54 |
+
|
| 55 |
+
# Predict button
|
| 56 |
+
if st.button("Predict"):
|
| 57 |
+
prediction_proba = model.predict_proba(input_data)[0, 1]
|
| 58 |
+
prediction = (prediction_proba >= classification_threshold).astype(int)
|
| 59 |
+
result = "purchase the package" if prediction == 1 else "not purchase the package"
|
| 60 |
+
st.write(f"Based on the information provided, the customer is likely to {result}.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 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
|