File size: 2,275 Bytes
a87d4f9
 
 
 
 
 
 
 
 
 
6301921
c3bb165
16a822a
a87d4f9
 
 
c3bb165
712c255
c3bb165
712c255
c3bb165
 
a87d4f9
c3bb165
6301921
a87d4f9
 
 
 
ea8673e
 
 
 
 
 
 
 
 
 
a87d4f9
 
 
 
 
 
ea8673e
 
a87d4f9
 
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
import streamlit as st
import pandas as pd
import requests

# Set the title of the Streamlit app
st.title("SuperKart Sales Prediction")

# Section for online prediction
st.subheader("Sales Prediction")

Product_Weight = st.number_input("Product Weight", min_value=0.01, value=16.54)
Product_Sugar_Content =  st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar", "reg"], index=0)
Product_Allocated_Area = st.number_input("Product Allocated area", value=0.144)
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'],  index=1)
Product_MRP = st.number_input("Product MRP", value=171.43)
Store_Id =  st.selectbox("Select Store", ['OUT004', 'OUT003', 'OUT001', 'OUT002'], index=1)
Store_Establishment_Year = st.number_input("Store Establishment year", value=1999)
Store_Size =   st.selectbox("Select Store Size", ['Medium', 'High', 'Small'], index=0)
Store_Location_City_Type = st.selectbox("Select Store Location", ['Tier 2', 'Tier 1', 'Tier 3'], index=1)
Store_Type = st.selectbox("Store Type", ['Supermarket Type2', 'Departmental Store', 'Supermarket Type1',
       'Food Mart'], index=1)



# Convert user input into a 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_Establishment_Year" : Store_Establishment_Year,
    "Store_Size" : Store_Size,
    "Store_Location_City_Type" : Store_Location_City_Type,
    "Store_Type" : Store_Type
  }])

# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
    response = requests.post("https://codingbuddy-superkartbackendapi.hf.space/v1/sales", json=input_data.to_dict(orient='records')[0])  # Send data to Flask API
    if response.status_code == 200:
        prediction = response.json()['Predicted_Sale']
        st.success(f"Predicted Sales: {prediction}")
    else:
        st.error("Error making prediction.")