Anusha3 commited on
Commit
9b6318a
·
verified ·
1 Parent(s): 05471c0

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +23 -0
  2. app.py +96 -0
  3. requirements.txt +7 -0
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from huggingface_hub import hf_hub_download
4
+ import joblib
5
+
6
+ # Download the model from the Model Hub
7
+ model_path = hf_hub_download(repo_id="Anusha3/superkart-model", filename="best_superkart_model_v1.joblib")
8
+
9
+ # Load the model
10
+ model = joblib.load(model_path)
11
+
12
+ # Streamlit UI for Customer Churn Prediction
13
+ st.title("SuperKart Package Prediction")
14
+ st.write("Fill the customer details below to predict if they'll purchase a travel package")
15
+
16
+ Product_Weight = st.slider("Product Weight (kg)", 0.5, 50.0, 10.0)
17
+
18
+ Product_Sugar_Content = st.selectbox(
19
+ "Product Sugar Content",
20
+ ["Low Sugar", "Regular", "No Sugar"]
21
+ )
22
+
23
+ Product_Allocated_Area = st.slider(
24
+ "Product Allocated Area (sq.ft)",
25
+ 0.1, 50.0, 5.0
26
+ )
27
+
28
+ Product_Type = st.selectbox(
29
+ "Product Type",
30
+ [
31
+ "Dairy", "Soft Drinks", "Meat", "Fruits and Vegetables",
32
+ "Household", "Baking Goods", "Snack Foods", "Frozen Foods",
33
+ "Breakfast", "Health and Hygiene"
34
+ ]
35
+ )
36
+
37
+ Product_MRP = st.number_input(
38
+ "Product MRP",
39
+ min_value=5.0,
40
+ max_value=1000.0,
41
+ value=120.0
42
+ )
43
+
44
+ Store_Id = st.selectbox(
45
+ "Store ID",
46
+ ["OUT001", "OUT002", "OUT003", "OUT004", "OUT005"]
47
+ )
48
+
49
+ Store_Establishment_Year = st.slider(
50
+ "Store Establishment Year",
51
+ 1985, 2022, 2010
52
+ )
53
+
54
+ Store_Size = st.selectbox(
55
+ "Store Size",
56
+ ["Small", "Medium", "High"]
57
+ )
58
+
59
+ Store_Location_City_Type = st.selectbox(
60
+ "Store Location City Type",
61
+ ["Tier 1", "Tier 2", "Tier 3"]
62
+ )
63
+
64
+ Store_Type = st.selectbox(
65
+ "Store Type",
66
+ ["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"]
67
+ )
68
+
69
+ # ----------------------------
70
+ # Prepare input data (IMPORTANT)
71
+ # ----------------------------
72
+ input_data = pd.DataFrame([{
73
+ "Product_Weight": Product_Weight,
74
+ "Product_Sugar_Content": Product_Sugar_Content,
75
+ "Product_Allocated_Area": Product_Allocated_Area,
76
+ "Product_Type": Product_Type,
77
+ "Product_MRP": Product_MRP,
78
+ "Store_Id": Store_Id,
79
+ "Store_Establishment_Year": Store_Establishment_Year,
80
+ "Store_Size": Store_Size,
81
+ "Store_Location_City_Type": Store_Location_City_Type,
82
+ "Store_Type": Store_Type
83
+ }])
84
+
85
+
86
+
87
+ # Set the classification threshold
88
+ classification_threshold = 0.45
89
+
90
+ # Predict button
91
+ if st.button("Predict"):
92
+ sales = model.predict(input_data)[0]
93
+
94
+ result = f"is expected to generate total sales of ₹ {sales:,.2f}"
95
+
96
+ st.write(f"Prediction: Store {result}")
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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