Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import requests | |
| st.title('SuperKart Sales Forecast') | |
| # Input fields with refined ranges based on df.describe() | |
| product_weight = st.number_input('Product Weight', min_value=4.555, max_value=21.35, value=12.8289) | |
| sugar_content = st.selectbox('Sugar Content', ['Low Sugar', 'Regular', 'No Sugar', 'reg']) | |
| allocated_area = st.number_input('Allocated Area', min_value=0.013, max_value=0.295, value=0.1393) | |
| 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']) | |
| mrp = st.number_input('Product MRP', min_value=31.29, max_value=266.89, value=141.15) | |
| est_year = st.number_input('Store Establishment Year', min_value=1985, max_value=2015, value=1999) # Changed to integer | |
| store_size = st.selectbox('Store Size', ['Medium', 'High', 'Small']) | |
| city_type = st.selectbox('City Type', ['Tier 1', 'Tier 2', 'Tier 3']) | |
| store_type = st.selectbox('Store Type', ['Supermarket Type1', 'Supermarket Type2', 'Departmental Store', 'Food Mart']) | |
| if st.button('Predict'): | |
| data = { | |
| 'Product_Weight': product_weight, | |
| 'Product_Sugar_Content': sugar_content, | |
| 'Product_Allocated_Area': allocated_area, | |
| 'Product_Type': product_type, | |
| 'Product_MRP': mrp, | |
| 'Store_Establishment_Year': est_year, | |
| 'Store_Size': store_size, | |
| 'Store_Location_City_Type': city_type, | |
| 'Store_Type': store_type, | |
| 'Store_Age': 2025 - est_year | |
| } | |
| try: | |
| response = requests.post('https://saibsund-superkart-flask-api.hf.space/predict', json=data) | |
| response.raise_for_status() | |
| prediction = response.json()['prediction'] | |
| st.write(f'Predicted Sales: ${prediction:.2f}') | |
| except requests.exceptions.RequestException as e: | |
| st.write(f"Error: {e}") | |