superKartSales / app.py
KarmaLoop's picture
Upload folder using huggingface_hub
cc05f1c verified
import streamlit as st
st.title("Store Sale Prediction")
# Batch Prediction
st.subheader("Online Prediction")
# Input fields for Store data
Product_Id = st.text_input("Product_Id : ")
Product_Weight = st.number_input("Product_Weight ", min_value=0, max_value=50, value=10)
Product_Sugar_Content = st.selectbox("Product_Sugar_Content ", ["Low Sugar", "Regular", and "no sugar"])
Product_Allocated_Area = st.number_input("Product_Allocated_Area", min_value=18, max_value=100, value=30)
Product_Type = st.selectbox("Product_Type", ["Fruits and Vegetables", "Snack Foods", "Frozen Foods",
"Dairy",
"Household",
"Baking Goods",
"Canned",
"Health and Hygiene",
"Meat",
"Soft Drinks",
"Breads",
"Hard Drinks",
"Others",
"Starchy Foods",
"Breakfast",
"Seafood" ])
Product_MRP = st.number_input("Product_MRP", min_value=0.0, value=1000.0)
Store_Id = st.selectbox("Store_Id", ["OUT004","OUT001", "OUT003", "OUT002" ])
Store_Establishment_Year = st.number_input("Store_Establishment_Year", ["Yes", "No"])
Store_Size = st.selectbox("Store_Size", ["Medium","High","Small"])
Store_Location_City_Type = st.Store_Location_City_Type("Store_Location_City_Type", ["Tier 2","Tier 1","Tier 3"])
Store_Type = st.Store_Type("Store_Type", ["Supermarket Type2","Supermarket Type1","Departmental Store","Food Mart"])
Store_data = {
'Product_Id' : Product_Id,
'Product_Weight': Product_Weight,
'Product_Sugar_Content': Product_Sugar_Content,
'Product_Allocated_Area': Product_Allocated_Area,
'Product_Type': Product_Type,
'Product_MRP': Product_MRP,
'Store_Id': Store_Id,
'Store_Establishment_Year': Store_Establishment_Year,
'Store_Size': Store_Size,
'Store_Location_City_Type': Store_Location_City_Type,
'Store_Type': Store_Type
}
if st.button("Predict", type='primary'):
response = requests.post("https://<user_name>-<space_name>.hf.space/v1/Store", json=Store_data) # enter user name and space name before running the cell
if response.status_code == 200:
result = response.json()
churn_prediction = result["Prediction"] # Extract only the value
st.write(f"Based on the information provided, the Store with ID {StoreID} is likely to {churn_prediction}.")
else:
st.error("Error in API request")
# Batch Prediction
st.subheader("Batch Prediction")
file = st.file_uploader("Upload CSV file", type=["csv"])
if file is not None:
if st.button("Predict for Batch", type='primary'):
response = requests.post("https://<user_name>-<space_name>.hf.space/v1/Storebatch", files={"file": file}) # enter user name and space name before running the cell
if response.status_code == 200:
result = response.json()
st.header("Batch Prediction Results")
st.write(result)
else:
st.error("Error in API request")