File size: 3,111 Bytes
da62c2d
 
 
 
 
 
 
 
 
 
 
d73e1c4
da62c2d
4653b7f
7b0f119
da62c2d
 
 
 
 
 
 
 
579b952
da62c2d
 
 
 
 
 
 
 
 
 
 
 
 
 
a200202
da62c2d
 
 
 
 
 
d73e1c4
da62c2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests
import streamlit as st
import pandas as pd

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

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

# Collect user input for product and store features
Product_Id=st.text_input("Product Id")
Product_Weight=st.number_input("Product Weight")
Product_Sugar_Content=st.selectbox("Product Sugar Content",['No Sugar', 'Low Sugar', 'Regular'])
Product_Allocated_Area=st.number_input("Product Allocated Area",min_value=0.0,max_value=1.0,value=0.001,step=0.001)# Allows increments of 0.001
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")
Store_Id=st.selectbox("Store Id",['OUT001', 'OUT002', 'OUT003', 'OUT004'])
Store_Size=st.selectbox("Store Size",['Small', 'Medium', 'High'])
Store_Location_City_Type=st.selectbox("Store Location City Type",['Tier 1', 'Tier 2', 'Tier 3'])
Store_Type=st.selectbox("Store Type",['Departmental Store', 'Supermarket Type1','Supermarket Type2',
       'Food Mart'])
Store_Establishment_Year=st.number_input("Store Establishment Year",min_value=1980, max_value=2025, value=1987)

# 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_Size':Store_Size,
    'Store_Location_City_Type':Store_Location_City_Type,
    'Store_Type':Store_Type,
    'Store_Establishment_Year':Store_Establishment_Year
}])
# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
  response = requests.post("https://Parthi07-SuperKartProductPricePrediction.hf.space/v1/sales", json=input_data.to_dict(orient='records')[0])
  if response.status_code == 200:
    prediction = response.json()['Predicted Product Sales Price']
    st.success(f"Product Sales for Product ID {Product_Id} is {prediction:,.2f}")
  else:
    st.error(f"Error making prediction: {response.status_code}")


# Section for batch prediction
st.subheader("Batch Product Sales Prediction")

# Allow users to upload a CSV file for batch prediction
uploaded_file = st.file_uploader("Upload a CSV file for Batch Product Sales Prediction", type=["csv"])

# Make batch prediction when the "Predict Batch" button is clicked
if uploaded_file is not None:
  if st.button("Predict Batch"):
    response = requests.post("https://Parthi07-SuperKartProductPricePrediction.hf.space/v1/salesbatch", files={'file': uploaded_file})
    if response.status_code == 200:
      prediction = response.json()
      st.success("Batch Product Sales Prediction Successful!")
      st.write(prediction)
    else:
      st.error(f"Error making batch prediction: {response.status_code}")