Spaces:
Sleeping
Sleeping
| 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") | |