import pandas as pd import requests import streamlit as st st.title('SuperKart Sale Prediction') # Inputs for prediction Product_Weight = st.number_input('Product_Weight', value=4.0) Product_Sugar_Content = st.selectbox('Product_Sugar_Content', ['No Sugar', 'Low Sugar', 'Regular', 'reg'], index=0) Product_Allocated_Area = st.number_input('Product_Allocated_Area', value=0.004) Product_Type = st.selectbox('Product_Type', ['Household', 'Soft Drinks', 'Fruits and Vegetables', 'Baking Goods', 'Meat', 'Dairy', 'Canned', 'Snack Foods', 'Frozen Foods', 'Health and Hygiene', 'Breads', 'Hard Drinks', 'Others', 'Starchy Foods', 'Breakfast', 'Seafood'], index=0) Product_MRP = st.number_input('Product_MRP', value=31.00) Store_Id = st.selectbox('Store_Id', ['OUT001', 'OUT003', 'OUT004', 'OUT002'], index=0) Store_Size = st.selectbox('Store_Size', ['Small', 'Medium', 'High'], index=0) Store_Location_City_Type = st.selectbox('Store_Location_City_Type', ['Tier 1', 'Tier 2', 'Tier 3'], index=1) Store_Type = st.selectbox('Store_Type', ['Supermarket Type1', 'Departmental Store', 'Supermarket Type2', 'Food Mart'], index=0) # Create input data as DataFrame 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_Size': Store_Size, 'Store_Location_City_Type': Store_Location_City_Type, 'Store_Type': Store_Type, }]) # Single prediction if st.button('Predict'): response = requests.post( 'https://Andrew2505-SKmodel.hf.space/v1/superkart_single', json = input_data.to_dict(orient="records")[0] ) if response.status_code == 200: prediction = response.json() st.success(f"Predicted Sale: {prediction['Sale']}") else: st.error(f"Error making prediction: {response.text}") # Batch prediction st.subheader('Batch Prediction') uploaded_file = st.file_uploader('Upload a CSV file', type=['csv']) if uploaded_file is not None: if st.button('Predict Batch'): response = requests.post( 'https://Andrew2505-Skmodel.hf.space/v1/superkart_batch', files={'file': uploaded_file} ) if response.status_code == 200: predictions = response.json() st.success("Batch predictions completed!") st.json(predictions) else: st.error(f"Error making batch prediction: {response.text}")