|
|
import requests |
|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
|
|
|
st.title("Sales Forecaster") |
|
|
|
|
|
|
|
|
st.subheader("Predicting Sales") |
|
|
|
|
|
|
|
|
Product_Id = st.text_input("Product ID", value="FD6114") |
|
|
Product_Weight = st.number_input("Product Weight", min_value=0.0, max_value=22.0, format="%.2f") |
|
|
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "reg"]) |
|
|
Product_Allocated_Area = st.number_input("Product Allocated Area (Ratio of Total Area) ", min_value=0.0, max_value=1.0, format="%.2f") |
|
|
Product_Type = st.selectbox("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("Price of Product", min_value=0.0, format="%.2f") |
|
|
Store_Id = st.selectbox("Store ID", ["OUT004", "OUT001", "OUT003", "OUT002"]) |
|
|
Store_Establishment_Year = st.number_input("Year of Store Establishment", min_value=1800, max_value=2025, value=2008) |
|
|
Store_Size = st.selectbox("Size of Store", ["High", "Medium", "Small"]) |
|
|
Store_Location_City_Type = st.selectbox("City Tier of the Store", ["Tier 1", "Tier 2", "Tier 3"]) |
|
|
Store_Type = st.selectbox("Type of Store", ["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"]) |
|
|
|
|
|
product_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://Anil28053-Backend.hf.space/v1/customer", json=product_data) |
|
|
if response.status_code == 200: |
|
|
result = response.json() |
|
|
sales_prediction = result["Prediction"] |
|
|
st.success(f"Based on the provided info, Product {Product_Id} is forecasted to generate sales of ₹{sales_prediction:.2f}") |
|
|
else: |
|
|
st.error("Error in API request") |
|
|
|
|
|
|
|
|
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://Anil28053-Backend.hf.space/v1/customerbatch", 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") |
|
|
|