Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +66 -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,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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="akskhare/Tourism-Packages", filename="best_tourism-packages_model_v1.joblib")
|
| 8 |
+
model = joblib.load(model_path)
|
| 9 |
+
|
| 10 |
+
# Streamlit UI for Machine Failure Prediction
|
| 11 |
+
st.title("Tourism Packages App")
|
| 12 |
+
st.write("""
|
| 13 |
+
This application predicts the likelihood of a machine failing based on its operational parameters.
|
| 14 |
+
Please enter the sensor and configuration data below to get a prediction.
|
| 15 |
+
""")
|
| 16 |
+
|
| 17 |
+
# User input
|
| 18 |
+
Age = st.number_input("Age in Yrs", min_value=1.0, max_value=100.0, step=0.1)
|
| 19 |
+
TypeofContact = st.selectbox("Type of Contact", ['Self Enquiry','Company Contacted'])
|
| 20 |
+
CityTier = st.selectbox("Type of City (Tier1=1,Tier2=2, Tier3=3)", [1,2,3])
|
| 21 |
+
DurationOfPitch = st.number_input("Pitch Time(Hrs)", min_value=0, max_value=1000, step=1)
|
| 22 |
+
Occupation = st.selectbox("Customer Occupation ", ['FreeLancer','Large Business','Salaried','Small Business'])
|
| 23 |
+
Gender = st.selectbox("Gender", ['Male','Female'])
|
| 24 |
+
NumberOfPersonVisiting= st.number_input("Number of Person Visiting", min_value=1, max_value=100, step=1)
|
| 25 |
+
NumberOfFollowups= st.number_input("Number of Followups", min_value=1, max_value=50, step=1)
|
| 26 |
+
ProductPitched= st.selectbox("Product Pitched", ['Basic','Standard','Premium'])
|
| 27 |
+
PreferredPropertyStar= st.number_input("Preferred Property Star", min_value=1, max_value=5, step=1)
|
| 28 |
+
MaritalStatus= st.selectbox("Marital Status", ['Married','Single','Divorced'])
|
| 29 |
+
NumberOfTrips= st.number_input("Number of Trips", min_value=1, max_value=100, step=1)
|
| 30 |
+
Passport= st.selectbox("Passport", ['Yes','No'])
|
| 31 |
+
OwnCar = st.selectbox("Car Owned (Yes=1, No=0)", [1, 0])
|
| 32 |
+
PitchSatisfactionScore= st.number_input("Pitch Satisfaction Score", min_value=1, max_value=5, step=1)
|
| 33 |
+
NumberOfChildrenVisiting= st.number_input("Number of Children Visiting", min_value=0, max_value=10, step=1)
|
| 34 |
+
Designation = st.text_input("Designation")
|
| 35 |
+
MonthlyIncome= st.number_input("Monthly Income:", min_value=1,step=100)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# Assemble input into DataFrame
|
| 39 |
+
input_data = pd.DataFrame([{
|
| 40 |
+
'Age in Yrs': Age,
|
| 41 |
+
'Type of Contact': TypeofContact,
|
| 42 |
+
'Type of City (Tier1=1,Tier2=2, Tier3=3)': CityTier,
|
| 43 |
+
'Pitch Time(Hrs)': DurationOfPitch,
|
| 44 |
+
'Customer Occupation': Occupation,
|
| 45 |
+
'Gender': Gender,
|
| 46 |
+
'Number of Person Visiting': NumberOfPersonVisiting,
|
| 47 |
+
'Number of Followups': NumberOfFollowups,
|
| 48 |
+
'Product Pitched': ProductPitched,
|
| 49 |
+
'Preferred Property Star': PreferredPropertyStar,
|
| 50 |
+
'Marital Status': MaritalStatus,
|
| 51 |
+
'Number of Trips': NumberOfTrips,
|
| 52 |
+
'Passport': Passport,
|
| 53 |
+
'Car Owned (Yes=1, No=0)': OwnCar,
|
| 54 |
+
'Pitch Satisfaction Score': PitchSatisfactionScore,
|
| 55 |
+
'Number of Children Visiting': NumberOfChildrenVisiting,
|
| 56 |
+
'Designation': Designation,
|
| 57 |
+
'Monthly Income': MonthlyIncome
|
| 58 |
+
|
| 59 |
+
}])
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
if st.button("ProdTaken"):
|
| 63 |
+
prediction = model.predict(input_data)[0]
|
| 64 |
+
result = "Product Bought" if prediction == 1 else "Not Taken"
|
| 65 |
+
st.subheader("Prediction Result:")
|
| 66 |
+
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.36.0
|
| 3 |
+
streamlit==1.52.0
|
| 4 |
+
joblib==1.5.2
|
| 5 |
+
scikit-learn==1.6.1
|
| 6 |
+
xgboost==3.1.2
|
| 7 |
+
mlflow==3.0.1
|