File size: 2,277 Bytes
55bfb1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d8b137
55bfb1b
6d8b137
55bfb1b
6d8b137
55bfb1b
6d8b137
55bfb1b
 
 
 
 
 
 
 
 
 
 
ebadee9
 
55bfb1b
 
 
 
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
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}")