|
|
import requests |
|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
st.title("Product Sales Prediction for Stores") |
|
|
|
|
|
|
|
|
st.subheader("Please fill details below for sales prediction") |
|
|
|
|
|
|
|
|
Product_Weight = st.number_input("Product_Weight (Weight of the product)", min_value=1.0, max_value=50.0,value=10.0) |
|
|
Product_Sugar_Content = st.selectbox("Product_Sugar_Content (Select the sugar content level of the product)", ['Low Sugar','Regular','No Sugar']) |
|
|
Product_Allocated_Area = st.number_input("Product_Allocated_Area (Area allocated for the product)", min_value=0.001,max_value=0.5,value=0.1) |
|
|
Product_Type = st.selectbox("Product_Type (Select the type of product)", ['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 (Enter the price of the product)", min_value=1.0,max_value=1000.0,value=100.0) |
|
|
Store_Id = st.selectbox("Store_Id (Select the Store ID)", ['OUT001','OUT002','OUT003','OUT004']) |
|
|
Store_Establishment_Year = st.selectbox("Store_Establishment_Year (Select the year the store was established)", [2009,1987,1999,1998]) |
|
|
Store_Size = st.selectbox("Store_Size (Select the store size)", ["Medium", "High","Small"]) |
|
|
Store_Location_City_Type = st.selectbox("Store_Location_City_Type (Select the type of city where the store is located)", ["Tier 2", "Tier 1","Tier 3"]) |
|
|
Store_Type = st.selectbox("Store_Type (Select the type of store)",['Supermarket Type2','Supermarket Type1','Departmental Store','Food Mart']) |
|
|
|
|
|
|
|
|
sales_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_Size': Store_Size, |
|
|
'Store_Location_City_Type': Store_Location_City_Type, |
|
|
} |
|
|
|
|
|
|
|
|
if st.button("Predict", type='primary'): |
|
|
response = requests.post("https://parthipan00410-salespredictionbackend.hf.space/v1/salesdata", json=sales_data) |
|
|
|
|
|
|
|
|
if response.status_code == 200: |
|
|
result = response.json() |
|
|
sales_prediciton = result["predicted_sales"] |
|
|
st.write(f"Here is the predicted sales value for the product: {sales_prediciton}.") |
|
|
else: |
|
|
st.error("Error in API request. Please check the backend or payload format.") |
|
|
|
|
|
|
|
|
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://parthipan00410-salespredictionbackend.hf.space/v1/salesdatabatch", files={"file": file}) |
|
|
|
|
|
|
|
|
if response.status_code == 200: |
|
|
result = response.json() |
|
|
st.header("Batch Prediction Results") |
|
|
st.write(result) |
|
|
else: |
|
|
st.error("Error in API request. Please check the backend or CSV format.") |
|
|
|