vijayendras commited on
Commit
0d47dad
·
verified ·
1 Parent(s): 8ca0b91

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +15 -12
  2. app.py +68 -0
  3. requirements.txt +6 -3
Dockerfile CHANGED
@@ -1,20 +1,23 @@
1
- FROM python:3.13.5-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
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
- EXPOSE 8501
 
 
 
 
 
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
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,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="vijayendras/Tourism-Package-Prediction", filename="tourism_package_prediction_model_v1.joblib")
8
+ model = joblib.load(model_path)
9
+
10
+ # Streamlit UI for Machine Failure Prediction
11
+ st.title("Tourism Package Prediction 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 years)", min_value=18, max_value=100, value=25)
19
+ typeofContract = st.selectbox("Type of Contract", ["Self Enquiry", "Company Invited"])
20
+ cityTier = st.number_input("City Tier", min_value=1, max_value=3, value=1)
21
+ durationOfPitch = st.number_input("Duration Of Pitch", min_value=5, max_value=150, value=25)
22
+ occupation = st.selectbox("Occupation", ["Salaried", "Small Business", 'Free Lancer', 'Large Business'])
23
+ gender = st.selectbox("Gender", ["Male", "Female"])
24
+ numberOfPersonVisiting = st.number_input("Number Of Person Visiting", min_value=1, max_value=6, value=1)
25
+ numberOfFollowups = st.number_input("Number Of Followups", min_value=1, max_value=10, value=1)
26
+ ProductPitched = st.selectbox("ProductPitched", ["Basic", "Standard", 'Deluxe', 'King', 'Super Deluxe'])
27
+ preferredPropertyStar = st.number_input("Preferred Property Star", min_value=1, max_value=5, value=1)
28
+ maritalStatus = st.selectbox("Marital Status", ["Married", "Single", 'Divorced','Unmarried'])
29
+ numberOfTrips = st.number_input("Number Of Trips", min_value=1, max_value=50, value=1)
30
+ passport = st.selectbox("Passport", ["0", "1"])
31
+ pitchSatisfactionScore = st.number_input("Pitch Satisfaction Score", min_value=1, max_value=5, value=1)
32
+ ownCar = st.selectbox("Own Car", ["0", "1"])
33
+ numberOfChildrenVisiting = st.number_input("Number Of Children Visiting",
34
+ min_value=0, max_value=5, value=0)
35
+ designation = st.selectbox("Designation", ["Executive", "Senior Manager", 'Manager', 'AVP', 'VP'])
36
+ monthlyIncome = st.number_input("Monthly Income",
37
+ min_value=0, max_value=100000, value=0)
38
+
39
+ # Assemble input into DataFrame
40
+
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
+
63
+
64
+ if st.button("Predict Tourism Package Taken"):
65
+ prediction = model.predict(input_data)[0]
66
+ result = "Package Taken" if prediction == 1 else "Package Not Taken"
67
+ st.subheader("Prediction Result:")
68
+ st.success(f"The model predicts: **{result}**")
requirements.txt CHANGED
@@ -1,3 +1,6 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
1
+ huggingface_hub==0.32.6
2
+ datasets==3.6.0
3
+ pandas==2.2.2
4
+ scikit-learn==1.6.0
5
+ xgboost==2.1.4
6
+ mlflow==3.0.1