Spaces:
Sleeping
Sleeping
File size: 3,011 Bytes
52acefd d642e6d 48e5558 e1a7938 d642e6d 48e5558 f7cd388 d642e6d 52acefd d642e6d 15d0397 6fbefd8 d642e6d 15d0397 d642e6d 48e5558 e1a7938 d642e6d 48e5558 15d0397 48e5558 e1a7938 d642e6d 48e5558 15d0397 48e5558 e1a7938 70a8d9e d642e6d 48e5558 15d0397 48e5558 e1a7938 d642e6d 48e5558 d642e6d 48e5558 e1a7938 6fbefd8 48e5558 52acefd d642e6d 52acefd 6fbefd8 d642e6d 6fbefd8 ca729e0 52acefd 820bbfa 853a1be 52acefd |
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 83 84 85 86 87 88 89 90 91 |
import streamlit as st
import requests
st.title("Super Kart Product Pricing Predictor")
# Input fields for product and store data
Product_Weight = st.number_input("Product Weight", min_value=0.0, value=10.00)
Product_Sugar_Content_Options = ["Low Sugar", "Regular", "No Sugar"]
Product_Sugar_Content = st.selectbox(
"Product Sugar Content: ",
Product_Sugar_Content_Options,
index = 0,
format_func=lambda x: x
)
Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value = 100.00)
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.00)
Store_Id_Options = ["OUT004", "OUT001", "OUT003", "OUT002"]
Store_Id = st.selectbox(
"Store Id: ",
Store_Id_Options,
index = 0,
format_func=lambda x: x
)
Product_Type_Options = [
'Dairy', 'Soft Drinks', 'Baking Goods', 'Meat', 'Frozen Foods', 'Snack Foods',
'Hard Drinks', 'Health and Hygiene', 'Breads', 'Fruits and Vegetables',
'Starchy Foods', 'Canned', 'Household', 'Others', 'Seafood', 'Breakfast'
]
Product_Type = st.selectbox(
"Product Type: ",
Product_Type_Options,
index = 0,
format_func=lambda x: x
)
Store_Size_Options = ["Medium", "Large", "Small"]
Store_Size = st.selectbox(
"Store Size: ",
Store_Size_Options,
index = 0,
format_func=lambda x: x
)
Store_Location_City_Type_Options = ["Tier 2", "Tier 1", "Tier 3"]
Store_Location_City_Type = st.selectbox(
"Store Location City Type: ",
Store_Location_City_Type_Options,
index = 0,
format_func=lambda x: x
)
Store_Type_Options = ['Supermarket Type2', 'Supermarket Type1', 'Departmental Store', 'Food Mart']
Store_Type = st.selectbox(
"Store Type: ",
Store_Type_Options,
index = 0,
format_func=lambda x: x
)
Store_Age_Years_Options = ["1987", "1998", "1999", "2009"]
Store_Age_Years = st.selectbox(
"Store Opening Year: ",
Store_Age_Years_Options
)
product_data = {
"Product_Weight": Product_Weight,
"Product_Sugar_Content": Product_Sugar_Content_Options.index(Product_Sugar_Content),
"Product_Allocated_Area": Product_Allocated_Area,
"Product_MRP": Product_MRP,
"Store_Id": Store_Id_Options.index(Store_Id),
"Store_Size": Store_Size_Options.index(Store_Size),
"Store_Location_City_Type": Store_Location_City_Type_Options.index(Store_Location_City_Type),
"Store_Type": Store_Type_Options.index(Store_Type),
"Store_Age_Years": int(Store_Age_Years),
"Product_Type": Product_Type_Options.index(Product_Type)
}
if st.button("Predict", type='primary'):
response = requests.post("https://rpeltier-SuperKartPredictorBackend.hf.space/v1/predict", json=product_data)
if response.status_code == 200:
result = response.json()
predicted_sales = result["PredictedPrice"]
st.write(f"Predicted Store Sales Total: ${predicted_sales :,.2f}")
else:
st.error("Error in API request")
|