File size: 2,766 Bytes
6a132c3
 
 
 
 
 
 
 
 
3683e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96f5efb
91f0b49
 
 
 
 
 
 
 
 
00ab35a
 
 
 
4998d8e
00ab35a
 
72b73be
 
00ab35a
a55f528
3230e7b
 
 
 
 
 
 
 
4998d8e
3230e7b
 
 
 
 
 
 
00ab35a
 
 
 
6a132c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

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)