| import streamlit as st |
| import pandas as pd |
| import requests |
|
|
| |
| |
|
|
| st.set_page_config(page_title="SuperKart Sales Predictor", page_icon="π") |
|
|
| st.title("π SuperKart Sales Prediction App") |
|
|
| st.write("Enter product and store details to predict expected sales.") |
|
|
| |
| product_mrp = st.number_input("Product MRP", min_value=0.0, max_value=10000.0, step=1.0) |
| store_type = st.selectbox("Store Type", ["Supermarket", "Grocery", "Online", "Other"]) |
| store_size = st.selectbox("Store Size", ["Small", "Medium", "Large"]) |
| sugar_content = st.selectbox("Sugar Content", ["Low", "Medium", "High"]) |
|
|
| |
| input_df = pd.DataFrame([{ |
| "Product_MRP": product_mrp, |
| "Store_Type": store_type, |
| "Store_Size": store_size, |
| "Sugar_Content": sugar_content |
| }]) |
|
|
| |
| if st.button("Predict Sales"): |
| Response = requests.post("https://kedhar4-superKart.hf.space/v1/kartperdiction", json=input_df.to_dict(orient="records")[0]) |
| if Response.status_code == 200: |
| prediction = Response.json()["prediction"] |
| st.success(f"Predicted Sales: {prediction}") |
| else: |
| st.error("Error in prediction") |
|
|
|
|
| |
| st. subheader("Batch Prediction") |
| file_upload = st.file_uploader("Upload Excel file for batch prediction", type=["xls", "xlsx"]) |
|
|
| if file_upload is not None: |
| file_details = {"file": file_upload.getvalue()} |
|
|
| response = requests.post("https://kedhar4-superKart.hf.space/v1/predict_batch", files=file_details) |
|
|
| if response.status_code == 200: |
| prediictions = response.json() |
| st.json(prediictions) |
| st.success("Batch prediction completed successfully!") |
| st.write(prediictions) |
| else: |
| st.error("Error in batch prediction") |
|
|
|
|
|
|
|
|