import streamlit as st import pandas as pd import requests # Load trained model #model = joblib.load("best_model.joblib") 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.") # Collect inputs from user 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"]) # Create input dataframe input_df = pd.DataFrame([{ "Product_MRP": product_mrp, "Store_Type": store_type, "Store_Size": store_size, "Sugar_Content": sugar_content }]) # Predict button 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") # section for batch 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")