| import requests |
| import streamlit as st |
| import pandas as pd |
|
|
| st.title("SuperKart Sales Prediction") |
|
|
| |
| st.subheader("Online Prediction") |
|
|
| |
| Product_Id = st.text_input("Product_Id") |
| Product_Weight = st.number_input("Product_Weight (Product's weight in KG)", min_value=0.0, max_value=900.0, value=2.0) |
| Product_Sugar_Content = st.selectbox("Product_Sugar_Content (Product's sugar content)", ["No Sugar", "Low Sugar", "Regular"]) |
| Product_Allocated_Area = st.number_input("Product_Allocated_Area (Fraction of total store area allocated to this product)", min_value=0.0, max_value=1.0, value=0.29) |
|
|
| product_type_values = [ |
| 'Meat', |
| 'Snack Foods', |
| 'Hard Drinks', |
| 'Dairy', |
| 'Canned', |
| 'Soft Drinks', |
| 'Health and Hygiene', |
| 'Baking Goods', |
| 'Bread', |
| 'Breakfast', |
| 'Frozen Foods', |
| 'Fruits and Vegetables', |
| 'Household', |
| 'Seafood', |
| 'Starchy Foods', |
| 'Others' |
| ] |
| Product_Type = st.selectbox("Product_Type (Type of the product)", product_type_values) |
|
|
| Product_MRP = st.number_input("Product_MRP (Max Retail Price of the product in dollars)", min_value=0.0, value=119.0) |
| Store_Size = st.selectbox("Store_Size (Size category of the store)", ["Small","Medium","High"]) |
| Store_Location_City_Type = st.selectbox("Store_Location_City_Type(Type of city in which store is located)", ["Tier 3", "Tier 2", "Tier 1"]) |
|
|
| store_type_values = [ |
| 'Departmental Store', |
| 'Supermarket Type1', |
| 'Supermarket Type2', |
| 'Food Mart' |
| ] |
| Store_Type = st.selectbox("Store_Type (Type of store depending on the products that are being sold there)", store_type_values) |
|
|
| product_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_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://AdarshRL-SalesPredictionBackend.hf.space/v1/product", json=product_data) |
| if response.status_code == 200: |
| result = response.json() |
| prediction = result["Prediction"]["Sales"] |
| st.write(f"Based on the information provided, the product with ID {Product_Id} is likely to generate sales of: {prediction}.") |
| 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://AdarshRL-SalesPredictionBackend.hf.space/v1/productbatch", 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") |
|
|