papsofts commited on
Commit
17448b9
·
verified ·
1 Parent(s): 8bb44ef

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -0
  2. app.py +43 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set the working directory inside the container
4
+ WORKDIR /app
5
+
6
+ # Copy all files from the current directory to the container's working directory
7
+ COPY . .
8
+
9
+ # Install dependencies from the requirements file without using cache to reduce image size
10
+ RUN pip install --no-cache-dir -r requirements.txt
11
+
12
+ # Define the command to start the application
13
+ CMD ["streamlit","run", "app.py"]
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import requests
4
+
5
+ # Streamlit UI for Customer Churn Prediction
6
+ st.title("SuperKart Store Sales Prediction App")
7
+ st.write("This tool predicts SuperKart Store sales based on their details. Enter the required information below.")
8
+
9
+ # Collect user input based on dataset columns
10
+ # ProductID = st.number_input("Product ID") # Product Id may not be useful in our prediction.
11
+ ProductWeight = st.number_input("Product Weight",min_value=0.0, max_value=500.0, value=10.0)
12
+ ProductAllocatedArea = st.number_input("Product Allocated Area",min_value=0.0001, max_value=1.0, value=0.02)
13
+ StoreEstablishmentYear = st.number_input("Store Establishment Year",min_value=1990, max_value=2025, value=2020)
14
+ ProductMRP = st.number_input("Product MRP",min_value=0.0, max_value=1000.0, value=100.0)
15
+ ProductSugarContent = st.selectbox("Product Sugar Content",["Low Sugar","Regular","No Sugar"])
16
+ StoreId = st.selectbox("Store ID",["OUT001","OUT002","OUT003","OUT004","OTHERS"])
17
+ StoreSize = st.selectbox("Store Size",["Small","Medium","High"])
18
+ StoreLocationCityType = st.selectbox("Store Location City Type",["Tier 1","Tier 2","Tier 3"])
19
+ StoreType = st.selectbox("Store Type",["Supermarket Type1","Supermarket Type2","Departmental Store", "Food Mart"])
20
+ ProductType = st.selectbox("Product Type",['Frozen Foods', 'Dairy', 'Canned', 'Baking Goods', 'Health and Hygiene', 'Snack Foods', 'Meat', 'Household', 'Hard Drinks', 'Fruits and Vegetables', 'Breads', 'Soft Drinks', 'Breakfast', 'Others', 'Starchy Foods', 'Seafood'])
21
+
22
+ # Convert categorical inputs to match model training
23
+ sales_data = {
24
+ 'Product_Weight': ProductWeight,
25
+ 'Product_Allocated_Area': ProductAllocatedArea,
26
+ 'Store_Establishment_Year': StoreEstablishmentYear,
27
+ 'Product_MRP': ProductMRP,
28
+ 'Product_Sugar_Content': ProductSugarContent,
29
+ 'Store_Id': StoreId,
30
+ 'Store_Size': StoreSize,
31
+ 'Store_Location_City_Type': StoreLocationCityType,
32
+ 'Store_Type': StoreType,
33
+ 'Product_Type': ProductType
34
+ }
35
+
36
+ if st.button("Predict", type='primary'):
37
+ response = requests.post("https://papsofts-SuperKart_Sales_Forecast_Backend.hf.space/v1/storeSales", json=sales_data) # enter user name and space name before running the cell
38
+ if response.status_code == 200:
39
+ result = response.json()
40
+ sales_prediction = result["Prediction"] # Extract only the value
41
+ st.write(f"Based on the information provided, the sales for the product mentioned is {sales_prediction}.")
42
+ else:
43
+ st.error("Error in API request")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ pandas==2.2.2
2
+ requests==2.28.1
3
+ streamlit==1.43.2