Spaces:
Sleeping
Sleeping
| import requests | |
| import streamlit as st | |
| import pandas as pd | |
| st.title("๐ Sales Forecasting App") | |
| st.subheader("๐ฎ Online Sales Prediction") | |
| # Input fields for product & store data | |
| Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "reg"]) | |
| Product_Type = st.selectbox("Product Type", [ | |
| "Fruits and Vegetables", "Snack Foods", "Frozen Foods", "Dairy", | |
| "Household", "Baking Goods", "Canned", "Health and Hygiene", | |
| "Meat", "Soft Drinks", "Bread", "Breads", "Hard Drinks", | |
| "Others", "Starchy Foods", "Breakfast", "Seafood" | |
| ]) | |
| Store_Id = st.selectbox("Store Id", ["OUT001", "OUT002", "OUT003", "OUT004"]) | |
| Store_Size = st.selectbox("Store Size", ["Medium", "High", "Low", "Small"]) | |
| 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"]) | |
| Product_Weight = st.number_input("Product Weight (kg)", min_value=0.0, value=5.0) | |
| Product_Price = st.number_input("Product Price ($)", min_value=0.0, value=50.0) | |
| Store_Area = st.number_input("Store Area (sq.ft)", min_value=0.0, value=2000.0) | |
| # Prepare input for API | |
| sales_data = { | |
| "Product_Weight": Product_Weight, | |
| "Product_Sugar_Content": Product_Sugar_Content, | |
| "Product_Allocated_Area": Store_Area, # was Store_Area | |
| "Product_Type": Product_Type, | |
| "Product_MRP": Product_Price, # was Product_Price | |
| "Store_Size": Store_Size, | |
| "Store_Age": 10 # placeholder or calculate | |
| } | |
| if st.button("Predict Sales", type='primary'): | |
| try: | |
| response = requests.post( | |
| "https://ankushwaghmare-backend.hf.space/v1/sales_forecast", | |
| json=sales_data | |
| ) | |
| if response.status_code == 200: | |
| result = response.json() | |
| predictionResult = result["Prediction"] | |
| #st.write(f"ased on the information provided, the prediction is likely to {predictionResult}.") | |
| st.success(f"Based on the information provided, {predictionResult}.") | |
| else: | |
| st.error(f"API Error {response.status_code}: {response.text}") | |
| except Exception as e: | |
| st.error(f"Request failed: {e}") | |