Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +110 -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=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 |
-
|
| 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
|