File size: 2,458 Bytes
cf3a435
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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("Online Prediction")

# Collect user input for property features

Product_Weight = st.number_input("Enter Product Weight", min_value=0.0, value=1.0)  
Product_Allocated_Area = st.number_input("Enter Product Allocated Area", min_value=0.0, value=1.0)
Product_MRP = st.number_input("Enter Product MRP", min_value=0.0, value=1.0)
Store_Established_Year = st.number_input("Enter Store Established Year", min_value=1980, value=1987, max_value=2025)# [2009 1999 1987 1998]
Product_Sugar_Content = st.selectbox("Select Product Sugar Content", ["No Sugar", "Low Sugar", "Regular"])
Store_Size = st.selectbox("Select Product Sugar Content", ["Small", "Medium", "High"])
Store_Location_City_Type = st.selectbox("Select Store Location City Type ", ["Tier 3", "Tier 2", "Tier 1"])
Product_Type = st.selectbox("Select Product Type ", ["Product_Type","Fruits and Vegetables","Snack Foods","Frozen Foods","Dairy","Household","Baking Goods","Canned","Health and Hygiene","Meat","Soft Drinks","Breads","Hard Drinks ","Others","Starchy Foods","Breakfast","Seafood" ])
Store_Type = st.selectbox("Select Store Type ", ["Supermarket Type2", "Supermarket Type1", "Departmental Store","Food Mart"])
Store_Id = st.selectbox("Select Store Id ", ["OUT001", "OUT002", "OUT003","OUT004"])

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
    "Product_Weight": Product_Weight,
    "Product_Allocated_Area": Product_Allocated_Area,
    "Product_MRP": Product_MRP,
    "Store_Established_Year": Store_Established_Year,
    "Product_Sugar_Content": Product_Sugar_Content,
    "Store_Size": Store_Size,
    "Store_Location_City_Type": Store_Location_City_Type,
    "Product_Type": Product_Type,
    "Store_Type": Store_Type,
    "Store_Id" :Store_Id  
  }])

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