Debashre2824 commited on
Commit
207d71b
·
verified ·
1 Parent(s): 17c62b6

Upload Streamlit app and model

Browse files
Files changed (3) hide show
  1. Dockerfile +7 -14
  2. SuperKart_Mode_v2_0.joblib +3 -0
  3. streamlit_app.py +32 -40
Dockerfile CHANGED
@@ -1,21 +1,14 @@
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- software-properties-common \
9
- git \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- COPY requirements.txt ./
13
- COPY src/ ./src/
14
 
 
15
  RUN pip3 install -r requirements.txt
16
 
17
- EXPOSE 8501
18
-
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
20
-
21
- 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"]
 
 
 
SuperKart_Mode_v2_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76964249af602d97766de8e0ae7aa9464ff20afeeb16ca2e4f3ff363288740c3
3
+ size 405737
streamlit_app.py CHANGED
@@ -1,52 +1,44 @@
1
-
2
  import streamlit as st
3
  import pandas as pd
4
  import joblib
5
 
6
  # Load trained model pipeline
7
- model = joblib.load('SuperKart_Mode_v1_0.joblib')
8
-
9
- # Streamlit app title
10
- st.title("🛒 Product Store Sales Prediction App")
11
- st.markdown("Enter product and store details below to predict sales.")
12
-
13
- # Input form
14
- with st.form("prediction_form"):
15
- product_weight = st.number_input("Product Weight (in kg)", min_value=1.0, max_value=50.0, value=13.5)
16
- product_allocated_area = st.number_input("Allocated Area (0 to 1)", min_value=0.001, max_value=1.0, value=0.08)
17
- product_mrp = st.number_input("Product MRP (₹)", min_value=1.0, max_value=1000.0, value=250.75)
18
- store_age = st.number_input("Store Age (in years)", min_value=1, max_value=100, value=20)
19
-
20
- product_sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High Sugar"])
21
- product_type = st.selectbox("Product Type", [
22
- "Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks",
23
- "Health and Hygiene", "Baking Goods", "Bread", "Breakfast", "Frozen Foods",
24
- "Fruits and Vegetables", "Household", "Seafood", "Starchy Foods", "Others"
25
- ])
26
- store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
27
- store_location = st.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
28
- store_type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
29
-
30
- submit = st.form_submit_button("Predict Sales")
31
-
32
- # Prediction logic
33
- if submit:
34
- input_dict = {
35
  "Product_Weight": [product_weight],
36
- "Product_Allocated_Area": [product_allocated_area],
37
  "Product_MRP": [product_mrp],
38
  "Store_Age": [store_age],
39
- "Product_Sugar_Content": [product_sugar_content],
40
  "Product_Type": [product_type],
41
  "Store_Size": [store_size],
42
- "Store_Location_City_Type": [store_location],
43
  "Store_Type": [store_type]
44
- }
45
-
46
- input_df = pd.DataFrame(input_dict)
47
-
48
- # Predict using loaded model
49
- prediction = model.predict(input_df)[0]
50
 
51
- # Show result
52
- st.success(f"📈 Predicted Product Store Sales: {prediction:,.2f}")
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  import joblib
4
 
5
  # Load trained model pipeline
6
+ model = joblib.load('SuperKart_Mode_v2_0.joblib') # Update the path if needed
7
+
8
+ # App title
9
+ st.title("Sales Predictor")
10
+
11
+ # Sidebar inputs
12
+ st.sidebar.header("Input Product & Store Details")
13
+
14
+ product_weight = st.sidebar.slider("Product Weight (kg)", 1.0, 50.0, 13.5)
15
+ allocated_area = st.sidebar.slider("Allocated Area (0 to 1)", 0.001, 1.0, 0.08)
16
+ product_mrp = st.sidebar.slider("Product MRP (₹)", 1.0, 1000.0, 250.75)
17
+ store_age = st.sidebar.slider("Store Age (years)", 1, 100, 20)
18
+
19
+ sugar_content = st.sidebar.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High Sugar"])
20
+ product_type = st.sidebar.selectbox("Product Type", [
21
+ "Meat", "Snack Foods", "Hard Drinks", "Dairy", "Canned", "Soft Drinks",
22
+ "Health and Hygiene", "Baking Goods", "Bread", "Breakfast", "Frozen Foods",
23
+ "Fruits and Vegetables", "Household", "Seafood", "Starchy Foods", "Others"
24
+ ])
25
+ store_size = st.sidebar.selectbox("Store Size", ["Small", "Medium", "High"])
26
+ city_tier = st.sidebar.selectbox("City Tier", ["Tier 1", "Tier 2", "Tier 3"])
27
+ store_type = st.sidebar.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
28
+
29
+ # Predict button
30
+ if st.sidebar.button("Predict Sales"):
31
+ input_data = pd.DataFrame({
 
 
32
  "Product_Weight": [product_weight],
33
+ "Product_Allocated_Area": [allocated_area],
34
  "Product_MRP": [product_mrp],
35
  "Store_Age": [store_age],
36
+ "Product_Sugar_Content": [sugar_content],
37
  "Product_Type": [product_type],
38
  "Store_Size": [store_size],
39
+ "Store_Location_City_Type": [city_tier],
40
  "Store_Type": [store_type]
41
+ })
 
 
 
 
 
42
 
43
+ prediction = model.predict(input_data)[0]
44
+ st.success(f"Predicted Sales: Rs{prediction:,.2f}")