Spaces:
Sleeping
Sleeping
Auto-deploy from GitHub Actions
Browse files- Dockerfile +15 -12
- app.py +65 -0
- requirements.txt +8 -2
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,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import joblib
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
| 6 |
+
|
| 7 |
+
# Load the trained model from Hugging Face Hub
|
| 8 |
+
model_path = hf_hub_download(repo_id="maddykan101/visit_with_us_model", filename="best_model.joblib")
|
| 9 |
+
model = joblib.load(model_path)
|
| 10 |
+
|
| 11 |
+
st.title("Travel Package Prediction App")
|
| 12 |
+
|
| 13 |
+
# Input form
|
| 14 |
+
with st.form("prediction_form"):
|
| 15 |
+
Age = st.number_input("Age", min_value=18, max_value=100, value=30)
|
| 16 |
+
TypeofContact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
|
| 17 |
+
CityTier = st.selectbox("City Tier", [1, 2, 3])
|
| 18 |
+
DurationOfPitch = st.number_input("Duration Of Pitch", min_value=0, max_value=50, value=10)
|
| 19 |
+
Occupation = st.selectbox("Occupation", ["Salaried", "Small Business", "Large Business", "Student", "Free Lancer"])
|
| 20 |
+
Gender = st.selectbox("Gender", ["Male", "Female"])
|
| 21 |
+
NumberOfPersonVisiting = st.number_input("Number Of Persons Visiting", min_value=1, max_value=10, value=1)
|
| 22 |
+
NumberOfFollowups = st.number_input("Number Of Follow-ups", min_value=0, max_value=20, value=1)
|
| 23 |
+
ProductPitched = st.selectbox("Product Pitched", ["Basic", "Standard", "Deluxe"])
|
| 24 |
+
PreferredPropertyStar = st.selectbox("Preferred Property Star", [1, 2, 3, 4, 5])
|
| 25 |
+
MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
|
| 26 |
+
NumberOfTrips = st.number_input("Number Of Trips", min_value=0, max_value=100, value=1)
|
| 27 |
+
Passport = st.selectbox("Passport", [0, 1])
|
| 28 |
+
PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3)
|
| 29 |
+
OwnCar = st.selectbox("Own Car", [0, 1])
|
| 30 |
+
NumberOfChildrenVisiting = st.number_input("Number Of Children Visiting", min_value=0, max_value=10, value=0)
|
| 31 |
+
Designation = st.selectbox("Designation", ["Manager", "Senior Manager", "Executive", "AVP"])
|
| 32 |
+
MonthlyIncome = st.number_input("Monthly Income", min_value=1000, max_value=100000, value=25000)
|
| 33 |
+
|
| 34 |
+
submit = st.form_submit_button("Predict")
|
| 35 |
+
|
| 36 |
+
if submit:
|
| 37 |
+
# Convert inputs to DataFrame
|
| 38 |
+
input_data = pd.DataFrame([{
|
| 39 |
+
"Age": Age,
|
| 40 |
+
"TypeofContact": TypeofContact,
|
| 41 |
+
"CityTier": CityTier,
|
| 42 |
+
"DurationOfPitch": DurationOfPitch,
|
| 43 |
+
"Occupation": Occupation,
|
| 44 |
+
"Gender": Gender,
|
| 45 |
+
"NumberOfPersonVisiting": NumberOfPersonVisiting,
|
| 46 |
+
"NumberOfFollowups": NumberOfFollowups,
|
| 47 |
+
"ProductPitched": ProductPitched,
|
| 48 |
+
"PreferredPropertyStar": PreferredPropertyStar,
|
| 49 |
+
"MaritalStatus": MaritalStatus,
|
| 50 |
+
"NumberOfTrips": NumberOfTrips,
|
| 51 |
+
"Passport": Passport,
|
| 52 |
+
"PitchSatisfactionScore": PitchSatisfactionScore,
|
| 53 |
+
"OwnCar": OwnCar,
|
| 54 |
+
"NumberOfChildrenVisiting": NumberOfChildrenVisiting,
|
| 55 |
+
"Designation": Designation,
|
| 56 |
+
"MonthlyIncome": MonthlyIncome
|
| 57 |
+
}])
|
| 58 |
+
|
| 59 |
+
# Predict
|
| 60 |
+
prediction = model.predict(input_data)[0]
|
| 61 |
+
|
| 62 |
+
if prediction == 1:
|
| 63 |
+
st.success("✅ Customer is likely to purchase the product.")
|
| 64 |
+
else:
|
| 65 |
+
st.error("❌ Customer is not likely to purchase the product.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,9 @@
|
|
| 1 |
-
|
| 2 |
pandas
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit>=1.33
|
| 2 |
pandas
|
| 3 |
+
scikit-learn
|
| 4 |
+
torch
|
| 5 |
+
transformers
|
| 6 |
+
datasets
|
| 7 |
+
mlflow
|
| 8 |
+
joblib
|
| 9 |
+
huggingface_hub>=0.23
|