Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import requests | |
| # Streamlit UI for Customer Churn Prediction | |
| st.title("SuperKart Sales Prediction App") | |
| st.write("This tool predicts SuperKart Store Product Sales based on their details. Enter the required information below.") | |
| # Collect user input based on dataset columns | |
| Product_Id = st.text_input("Enter a Product Identifier. This should start with one of the 3 Product Code values ('FD', 'NC', 'DR') followed by a 2/3 digit number.") | |
| Product_Weight = st.number_input("Product Weight", min_value=1, max_value=99) | |
| Product_Sugar_Content = st.selectbox("Select the Product Sugar Content Level", ['No Sugar', 'Low Sugar', 'Regular']) | |
| Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.004, max_value=0.3) | |
| Product_Type = st.selectbox("Select the Product Sugar Content Level", ['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", min_value=1, max_value=500) | |
| Store_Id = st.selectbox("Select Store ID", ['OUT001', 'OUT002', 'OUT003', 'OUT004']) | |
| Store_Establishment_Year = st.selectbox("Store Establishment Year", [1987, 1998, 1999, 2009]) | |
| Store_Size = st.selectbox("Select the correct store size?", ['High', 'Medium', 'Small']) | |
| Store_Location_City_Type = st.selectbox("Select the Store Location City type", ['Tier 1', 'Tier 2', 'Tier 3']) | |
| Store_Type = st.selectbox("Select the Store Type", ['Departmental Store', 'Food Mart', 'Supermarket Type2', 'Supermarket Type1']) | |
| # Convert categorical inputs to match model training | |
| customer_data = { | |
| 'Product_Id': Product_Id, | |
| '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_Establishment_Year': Store_Establishment_Year, | |
| 'Store_Size': Store_Size, | |
| 'Store_Location_City_Type': Store_Location_City_Type, | |
| 'Store_Type': Store_Type | |
| } | |
| if st.button("Predict", type='primary'): | |
| response = requests.post("https://SandeepMM-Backend.hf.space/v1/product", json=customer_data) # enter user name and space name before running the cell | |
| if response.status_code == 200: | |
| result = response.json() | |
| sales_prediction = result["Prediction"] # Extract only the value | |
| st.write(f"Based on the information provided, the total sales value {sales_prediction}.") | |
| else: | |
| st.error("Error in API request") | |