File size: 3,163 Bytes
172980d
 
 
 
 
 
 
 
 
 
 
3b15c51
172980d
3b15c51
172980d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a39eb3a
 
172980d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import requests
import streamlit as st
import pandas as pd

st.title("SuperKart Sales Prediction")

# Batch Prediction
st.subheader("Online Prediction")

# Input fields for product data
Product_Id = st.text_input("Product_Id")
Product_Weight = st.number_input("Product_Weight (Product's weight in KG)", min_value=0.0, max_value=900.0, value=2.0)
Product_Sugar_Content = st.selectbox("Product_Sugar_Content (Product's sugar content)", ["No Sugar", "Low Sugar", "Regular"])
Product_Allocated_Area = st.number_input("Product_Allocated_Area (Fraction of total store area allocated to this product)", min_value=0.0, max_value=1.0, value=0.29)

product_type_values = [
    'Meat', 
    'Snack Foods', 
    'Hard Drinks', 
    'Dairy', 
    'Canned', 
    'Soft Drinks', 
    'Health and Hygiene', 
    'Baking Goods', 
    'Bread', 
    'Breakfast', 
    'Frozen Foods', 
    'Fruits and Vegetables', 
    'Household', 
    'Seafood', 
    'Starchy Foods', 
    'Others'
]
Product_Type = st.selectbox("Product_Type (Type of the product)", product_type_values)

Product_MRP = st.number_input("Product_MRP (Max Retail Price of the product in dollars)", min_value=0.0, value=119.0)
Store_Size = st.selectbox("Store_Size (Size category of the store)", ["Small","Medium","High"])
Store_Location_City_Type = st.selectbox("Store_Location_City_Type(Type of city in which store is located)", ["Tier 3", "Tier 2", "Tier 1"])

store_type_values = [
    'Departmental Store', 
    'Supermarket Type1', 
    'Supermarket Type2', 
    'Food Mart'
]
Store_Type = st.selectbox("Store_Type (Type of store depending on the products that are being sold there)", store_type_values)

product_data = {
    'Product_Id': Product_Id,
    '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_Size': Store_Size,
    'Store_Location_City_Type': Store_Location_City_Type,
    'Store_Type': Store_Type
}

if st.button("Predict", type='primary'):
    response = requests.post("https://AdarshRL-SalesPredictionBackend.hf.space/v1/product", json=product_data)    # enter user name and space name before running the cell
    if response.status_code == 200:
        result = response.json()
        prediction = result["Prediction"]["Sales"]  # Extract only the value
        st.write(f"Based on the information provided, the product with ID {Product_Id} is likely to generate sales of: {prediction}.")
    else:
        st.error("Error in API request")

# Batch Prediction
st.subheader("Batch Prediction")

file = st.file_uploader("Upload CSV file", type=["csv"])
if file is not None:
    if st.button("Predict for Batch", type='primary'):
        response = requests.post("https://AdarshRL-SalesPredictionBackend.hf.space/v1/productbatch", files={"file": file})    # enter user name and space name before running the cell
        if response.status_code == 200:
            result = response.json()
            st.header("Batch Prediction Results")
            st.write(result)
        else:
            st.error("Error in API request")