| import streamlit as st |
| import pandas as pd |
| import requests |
|
|
| |
| st.title("SuperKart Product Total Sales Prediction") |
|
|
| |
| st.subheader("Online Prediction") |
|
|
| |
|
|
| |
| product_weight = st.number_input( |
| "Product Weight (in grams)", |
| min_value=0.0, value=100.0, step=0.1, |
| help="Weight of each product" |
| ) |
|
|
| |
| product_sugar_content = st.selectbox( |
| "Product Sugar Content", |
| ["Low Sugar", "Regular", "No Sugar"], |
| help="Sugar content of each product" |
| ) |
|
|
| |
| product_allocated_area = st.number_input( |
| "Product Allocated Area (0 to 1)", |
| min_value=0.0, max_value=1.0, value=0.2, step=0.01, |
| help="Ratio of the product's allocated display area to total display area in the store" |
| ) |
|
|
| |
| product_type = st.selectbox( |
| "Product Type", |
| [ |
| "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" |
| ], |
| help="Broad category for the product" |
| ) |
|
|
| |
| product_mrp = st.number_input( |
| "Product MRP (in ₹)", |
| min_value=1.0, value=100.0, step=1.0, |
| help="Maximum retail price of each product" |
| ) |
|
|
| |
| store_id = st.text_input( |
| "Store ID", |
| value="S101", |
| help="Unique identifier of the store" |
| ) |
|
|
| |
| store_establishment_year = st.number_input( |
| "Store Establishment Year", |
| min_value=1900, max_value=2025, value=2010, step=1, |
| help="Year the store was established" |
| ) |
|
|
| |
| store_size = st.selectbox( |
| "Store Size", |
| ["High", "Medium", "Small"], |
| help="Size of the store in square feet" |
| ) |
|
|
| |
| store_location_city_type = st.selectbox( |
| "Store Location City Type", |
| ["Tier 1", "Tier 2", "Tier 3"], |
| help="City type where store is located" |
| ) |
|
|
| |
| store_type = st.selectbox( |
| "Store Type", |
| ["Departmental Store", "Supermarket Type 1", "Supermarket Type 2", "Food Mart"], |
| help="Type of store based on products sold" |
| ) |
|
|
| |
|
|
| |
| input_data = pd.DataFrame([{ |
| '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"): |
| response = requests.post( |
| "https://SudeendraMG-SuperKartProductTotalSalesPredictionBackend.hf.space/v1/totalsales", |
| json=input_data.to_dict(orient='records')[0] |
| ) |
| |
| |
| if response.status_code == 200: |
| prediction = response.json()['Predicted Product Store Sales Total'] |
| st.success(f"Predicted Product Store Sales Total: {prediction}") |
| else: |
| st.error("Error making prediction.") |
|
|
| |
|
|
| |
| st.subheader("Batch Prediction") |
|
|
| |
| uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"]) |
|
|
| |
| if uploaded_file is not None: |
| if st.button("Predict Batch"): |
| |
| response = requests.post( |
| "https://SudeendraMG-SuperKartProductTotalSalesPredictionBackend.hf.space/v1/totalsalesbatch", |
| files={"file": uploaded_file} |
| ) |
| |
| |
| if response.status_code == 200: |
| predictions = response.json() |
| st.success("Batch predictions completed!") |
| st.write(predictions) |
| else: |
| st.error("Error making batch prediction.") |
|
|