trretretret's picture
Initial commit from automation
eab3196
import streamlit as st
import pandas as pd
import requests
st.title("SuperKart Sales Prediction")
st.subheader("Online Prediction")
product_weight = st.number_input("Product Weight (kg)", min_value=0.0, value=10.0)
product_allocated_area = st.number_input("Allocated Shelf Area (sq m)", min_value=0.0, value=0.05)
product_mrp = st.number_input("Product MRP (INR)", min_value=1.0, value=100.0)
store_est_year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2005)
product_sugar_content = st.selectbox("Sugar Content", ["Low Sugar", "No Sugar", "Regular"])
product_type = st.selectbox("Product Type", [
"Dairy", "Canned", "Baking Goods", "Frozen Foods", "Health and Hygiene",
"Snack Foods", "Soft Drinks", "Others"
])
store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
store_location = st.selectbox("Store Location Type", ["Tier 1", "Tier 2", "Tier 3"])
store_type = st.selectbox("Store Type", [
"Supermarket Type1", "Supermarket Type2", "Supermarket Type3",
"Grocery Store", "Food Mart", "Departmental Store"
])
input_data = pd.DataFrame([{
"Product_Weight": product_weight,
"Product_Allocated_Area": product_allocated_area,
"Product_MRP": product_mrp,
"Store_Establishment_Year": store_est_year,
"Product_Sugar_Content": product_sugar_content,
"Product_Type": product_type,
"Store_Size": store_size,
"Store_Location_City_Type": store_location,
"Store_Type": store_type
}])
if st.button("Predict Sales"):
response = requests.post(
"https://dhani10-SuperKartSalesPredictionBackend.hf.space/v1/sales",
json=input_data.to_dict(orient='records')[0]
)
if response.status_code == 200:
prediction = response.json()['predicted_sales']
st.success(f"Predicted Sales: ₹{round(prediction, 2)}")
else:
st.error(f"Error making prediction: {response.status_code} - {response.text}")
st.subheader("Batch Prediction")
uploaded_file = st.file_uploader("Upload a CSV file for batch prediction", type=["csv"])
if uploaded_file is not None:
if st.button("Predict Batch"):
response = requests.post(
"https://dhani10-SuperKartSalesPredictionBackend.hf.space/v1/salesbatch",
files={"file": uploaded_file}
)
if response.status_code == 200:
predictions = response.json()
st.success("Batch predictions completed!")
st.dataframe(pd.DataFrame(predictions, columns=["Predicted Sales (INR)"]))
else:
st.error(f"Error making batch prediction: {response.status_code} - {response.text}")