Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +70 -0
- requirements.txt +6 -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,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 from Hugging Face Hub
|
| 7 |
+
model_path = hf_hub_download(
|
| 8 |
+
repo_id="Sandhya777/tourism_package_prediction_model1",
|
| 9 |
+
filename="best_tourism_package_prediction_v2.joblib"
|
| 10 |
+
)
|
| 11 |
+
model = joblib.load(model_path)
|
| 12 |
+
|
| 13 |
+
# Streamlit UI for Insurance Charges Prediction
|
| 14 |
+
st.title("Tourism Package Prediction App")
|
| 15 |
+
st.write("""
|
| 16 |
+
This application predicts the **Tourism Package Prediction** based on personal and lifestyle details.
|
| 17 |
+
Please enter the required information below to get a prediction.
|
| 18 |
+
""")
|
| 19 |
+
|
| 20 |
+
# User input
|
| 21 |
+
age= st.number_input("Age", min_value=18, max_value=100, value=30, step=1)
|
| 22 |
+
typeofcontact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"])
|
| 23 |
+
citytier = st.selectbox("City Tier", [1, 2, 3])
|
| 24 |
+
durationofpitch = st.number_input("Duration of Pitch", min_value=1, max_value=100, value=10, step=1)
|
| 25 |
+
occupation= st.selectbox("Occupation", ["Salaried", "Freelancer"])
|
| 26 |
+
gender = st.selectbox("Gender", ["Male", "Female"])
|
| 27 |
+
numberofpersonvisiting = st.number_input("Number of People Visiting", min_value=1, max_value=10, value=2, step=1)
|
| 28 |
+
numberoffollowups = st.number_input("Number of Follow-ups", min_value=1, max_value=10, value=2, step=1)
|
| 29 |
+
productpitched= st.selectbox("Product Pitched", ["Basic", "Deluxe","Standard","King","Super Deluxe"])
|
| 30 |
+
preferredpropertystar= st.number_input("Preferred Property Star", min_value=1, max_value=5, value=3, step=1)
|
| 31 |
+
maritalstatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
|
| 32 |
+
numberoftrips = st.number_input("Number of Trips", min_value=1, max_value=10, value=2, step=1)
|
| 33 |
+
passport = st.selectbox("Passport", [0, 1])
|
| 34 |
+
pitchsatisfactionscore = st.number_input("Pitch Satisfaction Score", min_value=1, max_value=5, value=3, step=1)
|
| 35 |
+
owncar = st.selectbox("Own Car", [0, 1])
|
| 36 |
+
numberofchildrenvisiting = st.number_input("Number of Children Visiting", min_value=0, max_value=10, value=0, step=1)
|
| 37 |
+
designation = st.selectbox("Designation", ["Executive", "Managerial", "Professional", "Other"])
|
| 38 |
+
monthlyincome = st.number_input("Monthly Income", min_value=1000, max_value=100000, value=5000, step=100)
|
| 39 |
+
|
| 40 |
+
# Assemble input into DataFrame
|
| 41 |
+
input_data = pd.DataFrame([{
|
| 42 |
+
'Age': age,
|
| 43 |
+
'TypeofContact': typeofcontact,
|
| 44 |
+
'CityTier': citytier,
|
| 45 |
+
'DurationOfPitch': durationofpitch,
|
| 46 |
+
'Occupation': occupation,
|
| 47 |
+
'Gender': gender,
|
| 48 |
+
'NumberOfPersonVisiting': numberofpersonvisiting,
|
| 49 |
+
'NumberOfFollowups': numberoffollowups,
|
| 50 |
+
'ProductPitched': productpitched,
|
| 51 |
+
'PreferredPropertyStar': preferredpropertystar,
|
| 52 |
+
'MaritalStatus': maritalstatus,
|
| 53 |
+
'NumberOfTrips': numberoftrips,
|
| 54 |
+
'Passport': passport,
|
| 55 |
+
'PitchSatisfactionScore': pitchsatisfactionscore,
|
| 56 |
+
'OwnCar': owncar,
|
| 57 |
+
'NumberOfChildrenVisiting': numberofchildrenvisiting,
|
| 58 |
+
'Designation': designation,
|
| 59 |
+
'MonthlyIncome': monthlyincome
|
| 60 |
+
}])
|
| 61 |
+
|
| 62 |
+
# Set the classification threshold
|
| 63 |
+
classification_threshold = 0.45
|
| 64 |
+
|
| 65 |
+
# Predict button
|
| 66 |
+
if st.button("Predict"):
|
| 67 |
+
prediction_proba = model.predict_proba(input_data)[0, 1]
|
| 68 |
+
prediction = (prediction_proba >= classification_threshold).astype(int)
|
| 69 |
+
result = "Package Taken" if prediction == 1 else "Package not Taken"
|
| 70 |
+
st.write(f"Based on the information provided, the customer is likely to {result}.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 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
|