import streamlit as st import requests import pandas as pd st.title("SuperKart Product Sales Forecast") st.subheader("Online and Batch prediction") Product_Id= st.text_input('Product_Id') Product_Weight=st.number_input('Product_Weight',min_value=3.0,max_value=25.0,value=12.66) Product_Sugar_Content=st.selectbox('Product_Sugar_Content',['Low Sugar','Regular','No Sugar']) Product_Allocated_Area=st.number_input('Product_Allocated_Area',min_value=0.1,max_value=0.5,value=0.2) Product_Type=st.selectbox('Product_Type',['Frozen Foods', 'Dairy', 'Canned', 'Baking Goods', 'Health and Hygiene', 'Snack Foods', 'Meat', 'Household', 'Hard Drinks', 'Fruits and Vegetables', 'Breads', 'Soft Drinks', 'Breakfast', 'Others', 'Starchy Foods', 'Seafood']) Product_MRP=st.number_input('Product_MRP',min_value=30.0,max_value=270.0,value=146.74) Store_Id=st.selectbox('Store_Id',['OUT004', 'OUT003', 'OUT001', 'OUT002']) Store_Establishment_Year=st.number_input('Store_Establishment_Year',min_value=1981,max_value=2010,value=1990) Store_Size= st.selectbox('Store_Size',['Medium', 'High', 'Small']) Store_Location_City_Type=st.selectbox('Store_Location_City_Type',['Tier 2', 'Tier 1', 'Tier 3']) Store_Type=st.selectbox('Store_Type',['Supermarket Type2', 'Departmental Store', 'Supermarket Type1', 'Food Mart']) input_data={'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_Establishment_Year':Store_Establishment_Year, 'Store_Size':Store_Size, 'Store_Location_City_Type':Store_Location_City_Type, 'Store_Type':Store_Type,} # Logic for prediction of single record. if st.button('Predict',type='primary'): response=requests.post('https://siddhesh1981-Backendapi.hf.space/v1/data',json=input_data) if response.status_code==200: result=response.json() prediction=result['prediction'] st.success(f'Based on the information provided the forecasted sales for the superkart product_id {Product_Id} is {prediction}') else: st.error(response.text) # Logic for Prediction of batch records st.subheader("Batch Prediction") file2=st.file_uploader('Upload CSV File',type=['csv']) if file2 is not None: if st.button("Predict for Batch", type='primary'): response=requests.post('https://siddhesh1981-Backendapi.hf.space/v1/databatch',files={'file':file2}) if response.status_code==200: result=response.json() st.header("Batch Prediction Results") st.write(result) else: st.error(response.text)