| import requests |
| import streamlit as st |
| import pandas as pd |
|
|
| st.title("SmartKart Total Sales Prediction") |
| st.subheader("Online Prediction") |
|
|
| |
| Product_Weight = st.number_input("Product Weight (kg)", min_value=0.0, value=1.0) |
| Product_Allocated_Area = st.number_input("Product Allocated Area (sq ft)", min_value=0.0, value=10.0) |
| Product_MRP = st.number_input("Product MRP ($)", min_value=0.0, value=100.0) |
| Store_Age = st.number_input("Store Age (years)", min_value=0, value=10) |
|
|
| |
| Product_Sugar_Content = st.selectbox("Product Sugar Content", ["No Sugar", "Low Sugar", "Regular"]) |
| sugar_map = {"No Sugar": 0, "Low Sugar": 1, "Regular": 2} |
|
|
| Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"]) |
| size_map = {"Small": 1, "Medium": 2, "Large": 3} |
|
|
| Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"]) |
| tier_map = {"Tier 1": 1, "Tier 2": 2, "Tier 3": 3} |
|
|
| |
| Store_Type = st.selectbox("Store Type", [ |
| "Departmental Store", "Food Mart", |
| "Supermarket Type1", "Supermarket Type2" |
| ]) |
|
|
| Product_Type = st.selectbox("Product Type", [ |
| "Baking Goods", "Breads", "Breakfast", "Canned", "Dairy", |
| "Frozen Foods", "Fruits and Vegetables", "Hard Drinks", |
| "Health and Hygiene", "Household", "Meat", "Others", |
| "Seafood", "Snack Foods", "Soft Drinks", "Starchy Foods" |
| ]) |
|
|
| |
| payload = { |
| "Product_Weight": Product_Weight, |
| "Product_Allocated_Area": Product_Allocated_Area, |
| "Product_MRP": Product_MRP, |
| "Store_Age": Store_Age, |
| "Product_Sugar_Content_Ord": sugar_map[Product_Sugar_Content], |
| "Store_Size_Ord": size_map[Store_Size], |
| "Store_Location_City_Type_Ord": tier_map[Store_Location_City_Type], |
| "Store_Type": Store_Type, |
| "Product_Type": Product_Type |
| } |
|
|
| |
| if st.button("Predict Total Sales", type="primary"): |
| response = requests.post( |
| "https://tifischer-smartkart-prediction-backend.hf.space/v1/predict", |
| json=payload, |
| timeout=30 |
| ) |
| if response.status_code == 200: |
| result = response.json() |
| st.success(f"Predicted Total Sales: ${result['Predicted_Total_Sales']}") |
| else: |
| st.error(f"Error in API request: {response.status_code}") |
|
|