sp1505 commited on
Commit
d30a597
·
verified ·
1 Parent(s): 41c21c7

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -13
  2. app.py +42 -0
  3. requirements.txt +3 -3
Dockerfile CHANGED
@@ -1,20 +1,15 @@
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-slim
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
+ # Define the command to run the Streamlit app on port 8501 and make it accessible externally
14
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
15
 
 
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import requests
4
+
5
+ # Streamlit UI for Customer Churn Prediction
6
+ st.title("Product Sales Prediction App")
7
+ st.write("This tool predicts production sales prediction. Enter the required information below.")
8
+
9
+ # Collect user input based on dataset columns
10
+ weight = st.number_input("Product Weight", min_value=1, max_value=99999999)
11
+ sugarcontent = st.selectbox("Product Sugar Content", ["Low Sugar", "No Sugar", "Regular Sugar", "reg"])
12
+ area = st.number_input("Product allocated area", min_value=1, max_value=9999999)
13
+ producttype = st.selectbox("Product type", ["Frozen Foods", "Dairy", "Canned", "Baking Goods", "Health and Hygiene", "Snack Foods", "Meat", "Household", "Hard Drinks", "Fruits and Vegetables",
14
+ "Breads", "Others", "Starchy Foods", Seafood"])
15
+ productmrp = st.number_input("Product MRP", min_val=1, max_value=9999999)
16
+ year = st.number_input("Store establishment year", min_value=1985, max_val=2024)
17
+ storesize = st.selectbox("store size", ["Small", "Medium", "High"])
18
+ citytype = st.number_input("City type", ["Tier1", "Tier2", "Tier3"])
19
+ storetype = st.selectbox("store type", ["Supermarket Type1", "Supermarket Type2", "Food Mart", "Departmental Store"])
20
+
21
+ # Convert categorical inputs to match model training
22
+ customer_data = {
23
+ 'Product Weight': weight
24
+ 'Product Sugar Content':sugarcontent,
25
+ 'Product allocated area': area,
26
+ 'Product Type': producttype,
27
+ 'Product MRP': productmrp,
28
+ 'Store establishment year': year,
29
+ 'store size': storesize,
30
+ 'City type': citytype,
31
+ 'store type': storetype,
32
+ }
33
+
34
+
35
+ if st.button("Predict", type='primary'):
36
+ response = requests.post("https://sp1505-frontend.hf.space/v1/customer", json=customer_data) # enter user name and space name before running the cell
37
+ if response.status_code == 200:
38
+ result = response.json()
39
+ churn_prediction = result["Prediction"] # Extract only the value
40
+ st.write(f"Based on the information provided, the customer with ID {CustomerID} is likely to {churn_prediction}.")
41
+ else:
42
+ st.error("Error in API request")
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ pandas==2.2.2
2
+ requests==2.28.1
3
+ streamlit==1.43.2