File size: 2,258 Bytes
6c33eeb
 
 
 
 
 
 
 
 
 
 
 
 
46cdfcd
e3e8eb3
46cdfcd
a8e2525
 
6c33eeb
 
 
 
a8e2525
 
 
6c33eeb
 
a8e2525
6c33eeb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f470ec0
6c33eeb
834f1d1
 
6c33eeb
 
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

import streamlit as st
import pandas as pd
import requests

# Set the title of the Streamlit app
st.title("Superkart Product sales revenue Predictor")

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

# Collect user input for property features

Product_Weight = st.number_input("Product Weight", min_value=4.0, max_value=25.0, step=1.0, value=15.14)
Product_Allocated_Area = st.number_input("Allocated Display Area Ratio", min_value=0.004, max_value=0.3, step=0.001,value=0.052,format="%.3f")
Product_MRP = st.number_input("Product MRP", min_value=10.0, max_value=500.0, step=1.0, value=148.06)
Product_Sugar_Content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
Product_Type = st.selectbox("Product Type", [
        "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"
    ])
Store_Size = st.selectbox("Store Size", ["High", "Medium", "Low"])
Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
Store_Type = st.selectbox("Store Type", [
        "Departmental Store","Supermarket Type 1","Supermarket Type 2","Food Mart"
    ])
Store_Id = st.selectbox("Store Id", ["OUT001","OUT002","OUT003","OUT004"])

# 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_Size': Store_Size,
    'Store_Location_City_Type': Store_Location_City_Type,
    'Store_Type': Store_Type,
    'Store_Id': Store_Id
}])

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