Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +75 -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,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
# Download and load the model
|
| 7 |
+
model_path = hf_hub_download(repo_id="PSstark/Machine-Learning-Prediction", filename="best_prediction_model_v1.joblib")
|
| 8 |
+
model = joblib.load(model_path)
|
| 9 |
+
|
| 10 |
+
# Streamlit UI for Machine Failure Prediction
|
| 11 |
+
st.title("Tourism Product Purchase Prediction App")
|
| 12 |
+
st.write("""
|
| 13 |
+
Welcome to the **Tourism Product Purchase Prediction App**! 🌍✨
|
| 14 |
+
|
| 15 |
+
This tool predicts whether a customer is likely to purchase a tourism product based on their personal details, preferences, and interaction history.
|
| 16 |
+
|
| 17 |
+
Please provide the customer information below, and the model will estimate the likelihood of them taking the product.
|
| 18 |
+
""")
|
| 19 |
+
|
| 20 |
+
# Basic demographic info
|
| 21 |
+
age = st.number_input("Customer Age", min_value=18, max_value=80, value=35)
|
| 22 |
+
gender = st.selectbox("Gender", ["Male", "Female"])
|
| 23 |
+
marital_status = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
|
| 24 |
+
|
| 25 |
+
# Contact and occupation info
|
| 26 |
+
typeof_contact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
|
| 27 |
+
occupation = st.selectbox("Occupation", ["Salaried", "Small Business", "Large Business", "Free Lancer"])
|
| 28 |
+
|
| 29 |
+
# Travel and product preferences
|
| 30 |
+
city_tier = st.selectbox("City Tier", [1, 2, 3])
|
| 31 |
+
product_pitched = st.selectbox("Product Pitched", ["Basic", "Deluxe", "Standard", "Super Deluxe", "King"])
|
| 32 |
+
designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP", "VP"])
|
| 33 |
+
|
| 34 |
+
# Numeric customer interaction details
|
| 35 |
+
duration_of_pitch = st.number_input("Duration of Pitch (minutes)", min_value=0.0, max_value=100.0, value=10.0)
|
| 36 |
+
number_of_person_visiting = st.number_input("Number of Persons Visiting", min_value=1, max_value=10, value=2)
|
| 37 |
+
number_of_followups = st.number_input("Number of Follow-ups", min_value=0, max_value=20, value=2)
|
| 38 |
+
preferred_property_star = st.selectbox("Preferred Property Star", [1, 2, 3, 4, 5])
|
| 39 |
+
number_of_trips = st.number_input("Number of Trips Taken", min_value=0, max_value=50, value=5)
|
| 40 |
+
pitch_satisfaction_score = st.slider("Pitch Satisfaction Score", min_value=1, max_value=5, value=3)
|
| 41 |
+
|
| 42 |
+
# Additional info
|
| 43 |
+
passport = st.selectbox("Passport", [0, 1])
|
| 44 |
+
own_car = st.selectbox("Own Car", [0, 1,2,3])
|
| 45 |
+
number_of_children_visiting = st.number_input("Number of Children Visiting", min_value=0, max_value=10, value=0)
|
| 46 |
+
monthly_income = st.number_input("Monthly Income", min_value=0.0, max_value=1000000.0, value=25000.0)
|
| 47 |
+
|
| 48 |
+
# 📊 Assemble all inputs into a DataFrame
|
| 49 |
+
input_data = pd.DataFrame([{
|
| 50 |
+
'Age': age,
|
| 51 |
+
'TypeofContact': typeof_contact,
|
| 52 |
+
'CityTier': city_tier,
|
| 53 |
+
'DurationOfPitch': duration_of_pitch,
|
| 54 |
+
'Occupation': occupation,
|
| 55 |
+
'Gender': gender,
|
| 56 |
+
'NumberOfPersonVisiting': number_of_person_visiting,
|
| 57 |
+
'NumberOfFollowups': number_of_followups,
|
| 58 |
+
'ProductPitched': product_pitched,
|
| 59 |
+
'PreferredPropertyStar': preferred_property_star,
|
| 60 |
+
'MaritalStatus': marital_status,
|
| 61 |
+
'NumberOfTrips': number_of_trips,
|
| 62 |
+
'Passport': passport,
|
| 63 |
+
'PitchSatisfactionScore': pitch_satisfaction_score,
|
| 64 |
+
'OwnCar': own_car,
|
| 65 |
+
'NumberOfChildrenVisiting': number_of_children_visiting,
|
| 66 |
+
'Designation': designation,
|
| 67 |
+
'MonthlyIncome': monthly_income
|
| 68 |
+
}])
|
| 69 |
+
|
| 70 |
+
# 🔮 Make prediction
|
| 71 |
+
if st.button("Predict Purchase"):
|
| 72 |
+
prediction = model.predict(input_data)[0]
|
| 73 |
+
result = "✅ Customer is Likely to Purchase the Product" if prediction == 1 else "❌ Customer is Unlikely to Purchase the Product"
|
| 74 |
+
st.subheader("Prediction Result:")
|
| 75 |
+
st.success(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
|