Upload folder using huggingface_hub
Browse files- Dockerfile +20 -13
- app.py +96 -0
- requirements.txt +6 -2
Dockerfile
CHANGED
|
@@ -1,20 +1,27 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
curl \
|
| 8 |
-
git \
|
| 9 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
|
| 12 |
-
COPY
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
| 1 |
+
# Use a lightweight Python image
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# Prevents Python from writing .pyc files and buffering stdout/stderr
|
| 5 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
+
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
+
# Set working directory
|
| 9 |
+
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Copy project files
|
| 12 |
+
COPY . /app
|
| 13 |
|
| 14 |
+
# Upgrade pip and install dependencies
|
| 15 |
+
RUN pip install --upgrade pip \
|
| 16 |
+
&& pip install -r tourism_project/deployment/requirements.txt
|
| 17 |
|
| 18 |
+
# Expose the port used by Streamlit
|
| 19 |
+
EXPOSE 7860
|
| 20 |
|
| 21 |
+
# Streamlit specific environment variables (optional tweaks)
|
| 22 |
+
ENV STREAMLIT_SERVER_HEADLESS=true
|
| 23 |
+
ENV STREAMLIT_SERVER_PORT=7860
|
| 24 |
+
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
| 25 |
|
| 26 |
+
# Default command to run the Streamlit app
|
| 27 |
+
CMD ["streamlit", "run", "tourism_project/deployment/app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
app.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
MODEL_REPO_ID = "bhumitps/tourism_model"
|
| 9 |
+
MODEL_FILENAME = "best_tourism_model_v1.joblib"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@st.cache_resource
|
| 13 |
+
def load_model():
|
| 14 |
+
model_path = hf_hub_download(
|
| 15 |
+
repo_id=MODEL_REPO_ID,
|
| 16 |
+
filename=MODEL_FILENAME,
|
| 17 |
+
repo_type="model",
|
| 18 |
+
)
|
| 19 |
+
model = joblib.load(model_path)
|
| 20 |
+
return model
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
model = load_model()
|
| 24 |
+
|
| 25 |
+
st.title("Wellness Tourism Package Purchase Prediction")
|
| 26 |
+
|
| 27 |
+
st.write(
|
| 28 |
+
"""
|
| 29 |
+
Predict whether a customer is likely to purchase the **Wellness Tourism Package**.
|
| 30 |
+
|
| 31 |
+
Fill in the customer details below and click **Predict**.
|
| 32 |
+
"""
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# --- Input fields ---
|
| 36 |
+
col1, col2 = st.columns(2)
|
| 37 |
+
|
| 38 |
+
with col1:
|
| 39 |
+
Age = st.number_input("Age", min_value=0, max_value=100, value=35)
|
| 40 |
+
CityTier = st.selectbox("CityTier", options=[1, 2, 3], index=0)
|
| 41 |
+
DurationOfPitch = st.number_input("DurationOfPitch (minutes)", min_value=0, max_value=300, value=15)
|
| 42 |
+
NumberOfPersonVisiting = st.number_input("NumberOfPersonVisiting", min_value=1, max_value=20, value=2)
|
| 43 |
+
NumberOfFollowups = st.number_input("NumberOfFollowups", min_value=0, max_value=20, value=2)
|
| 44 |
+
PreferredPropertyStar = st.selectbox("PreferredPropertyStar", options=[1, 2, 3, 4, 5], index=2)
|
| 45 |
+
NumberOfTrips = st.number_input("NumberOfTrips", min_value=0, max_value=50, value=1)
|
| 46 |
+
NumberOfChildrenVisiting = st.number_input("NumberOfChildrenVisiting", min_value=0, max_value=10, value=0)
|
| 47 |
+
MonthlyIncome = st.number_input("MonthlyIncome", min_value=0, max_value=1000000, value=50000, step=1000)
|
| 48 |
+
|
| 49 |
+
with col2:
|
| 50 |
+
TypeofContact = st.selectbox("TypeofContact", options=["Self Enquiry", "Company Invited", "Other"])
|
| 51 |
+
Occupation = st.selectbox("Occupation", options=["Salaried", "Self Employed", "Free Lancer", "Other"])
|
| 52 |
+
Gender = st.selectbox("Gender", options=["Male", "Female", "Other"])
|
| 53 |
+
ProductPitched = st.text_input("ProductPitched (raw value)", value="Basic")
|
| 54 |
+
MaritalStatus = st.selectbox("MaritalStatus", options=["Married", "Single", "Divorced", "Other"])
|
| 55 |
+
Passport = st.selectbox("Passport", options=["No", "Yes"])
|
| 56 |
+
PitchSatisfactionScore = st.selectbox("PitchSatisfactionScore", options=[1, 2, 3, 4, 5], index=2)
|
| 57 |
+
OwnCar = st.selectbox("OwnCar", options=["No", "Yes"])
|
| 58 |
+
Designation = st.selectbox("Designation", options=["Executive", "Manager", "Senior Manager", "AVP", "VP", "Other"])
|
| 59 |
+
|
| 60 |
+
st.markdown("---")
|
| 61 |
+
|
| 62 |
+
if st.button("Predict"):
|
| 63 |
+
# Build a single-row DataFrame. Column names must match training features.
|
| 64 |
+
input_data = pd.DataFrame([{
|
| 65 |
+
"Age": Age,
|
| 66 |
+
"TypeofContact": TypeofContact,
|
| 67 |
+
"CityTier": CityTier,
|
| 68 |
+
"DurationOfPitch": DurationOfPitch,
|
| 69 |
+
"Occupation": Occupation,
|
| 70 |
+
"Gender": Gender,
|
| 71 |
+
"NumberOfPersonVisiting": NumberOfPersonVisiting,
|
| 72 |
+
"NumberOfFollowups": NumberOfFollowups,
|
| 73 |
+
"ProductPitched": ProductPitched,
|
| 74 |
+
"PreferredPropertyStar": PreferredPropertyStar,
|
| 75 |
+
"MaritalStatus": MaritalStatus,
|
| 76 |
+
"NumberOfTrips": NumberOfTrips,
|
| 77 |
+
"Passport": Passport,
|
| 78 |
+
"PitchSatisfactionScore": PitchSatisfactionScore,
|
| 79 |
+
"OwnCar": OwnCar,
|
| 80 |
+
"NumberOfChildrenVisiting": NumberOfChildrenVisiting,
|
| 81 |
+
"Designation": Designation,
|
| 82 |
+
"MonthlyIncome": MonthlyIncome,
|
| 83 |
+
}])
|
| 84 |
+
|
| 85 |
+
# The training pipeline (data_prep + train.py) used label encoding and scaling.
|
| 86 |
+
# This app relies on the model pipeline's own preprocessing, so we pass raw values.
|
| 87 |
+
pred_proba = model.predict_proba(input_data)[0][1]
|
| 88 |
+
pred_label = model.predict(input_data)[0]
|
| 89 |
+
|
| 90 |
+
st.subheader("Prediction Result")
|
| 91 |
+
if pred_label == 1:
|
| 92 |
+
st.success(f"Customer is **LIKELY** to purchase the Wellness Tourism Package. (Probability: {pred_proba:.2%})")
|
| 93 |
+
else:
|
| 94 |
+
st.info(f"Customer is **UNLIKELY** to purchase the Wellness Tourism Package. (Probability: {pred_proba:.2%})")
|
| 95 |
+
|
| 96 |
+
st.caption("Note: probabilities are model-based estimates and not guarantees.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
| 1 |
-
altair
|
| 2 |
pandas
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
pandas
|
| 2 |
+
numpy
|
| 3 |
+
scikit-learn
|
| 4 |
+
xgboost
|
| 5 |
+
streamlit
|
| 6 |
+
huggingface_hub
|
| 7 |
+
joblib
|