Shaggys86's picture
Upload folder using huggingface_hub
c2957c0 verified
import streamlit as st
import pandas as pd
import requests
# Streamlit UI for SuperKart Product store Revenue Prediction
st.title("SuperKart Product store Revenue Prediction App")
st.write("This app forecast the sales revenue of its outlets for various products.")
st.write("Fill in the required inputs below and get a prediction.")
Product_type_values = ["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"]
sorted_options = sorted(Product_type_values)
# Collect user input
Product_Weight= st.number_input("Please enter the Product Weight", min_value=0.0, value=0.0)
Product_Sugar_Content= st.selectbox('Please select Product Sugar Content',["Please select","Low Sugar","No Sugar","Regular","reg"], index=1)
Product_Allocated_Area= st.number_input("Please enter the amount of area to be allocated for the product", min_value=0.0, value=0.0)
Product_Type= st.selectbox("Please select product Type",sorted_options)
Product_MRP= st.number_input("Please enter the Product MRP", min_value=0.0, value=0.0)
#Store_Id= st.selectbox("Please select store",["Please select","OUT001","OUT002","OUT003","OUT004"])
#Store_Establishment_Year= st.text_input("Store Establishment Year (Autofilled)", st.session_state.Store_Establishment_Year_value, key="Store_Establishment_Year_value")
#Store_Size= st.text_input("Store size (Autofilled)", st.session_state.Store_Size_value, key="Store_Size_value")
#Store_Location_City_Type= st.text_input("Store location City type (Autofilled)", st.session_state.Store_Location_City_Type_value, key="Store_Location_City_Type_value")
#Store_Type= st.text_input("Store Type (Autofilled)", st.session_state.Store_Type_value, key="Store_Type_value")
Store_Id= st.selectbox("Please select store",["OUT001","OUT002","OUT003","OUT004"])
Store_Establishment_Year= st.selectbox("Store Establishment Year",[1987, 1998, 1999, 2009])
Store_Size= st.selectbox("Store size ", ["High","Medium","Small"])
Store_Location_City_Type= st.selectbox("Store location City type ", ["Tier 1","Tier 2","Tier 3"])
Store_Type= st.selectbox("Store Type ", ["Supermarket Type2", "Supermarket Type1","Food Mart", "Departmental Store"])
# Create input DataFrame
input_data = {
'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://Shaggys86-SuperKartProductSalesPrediction.hf.space/v1/product", json=input_data) # enter user name and space name before running the cell
if response.status_code == 200:
result = response.json()
predicted_sales = result["Predicted_Product_store_Sales"]
st.success(f"The Predicted Product Store Sales Value: {predicted_sales}")
else:
st.error("Error in API request")