File size: 4,727 Bytes
5fde683
 
 
fcf91b1
5fde683
 
fcf91b1
5fde683
 
fcf91b1
5fde683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fcf91b1
5fde683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fcf91b1
 
5fde683
fcf91b1
5fde683
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import streamlit as st
import pandas as pd
import requests

# Set the title of the Streamlit app
st.title("Sales Prediction")

# Section for online prediction
st.subheader("Online Prediction")

# Collect user input for product and store features
Product_Weight = st.number_input("Product Weight", min_value=0.0, value=15.0)
Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=200.0)
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1900, max_value=2024, value=2000)
Product_Sugar_Content_No_Sugar = st.selectbox("Product Sugar Content No Sugar", [0, 1])
Product_Sugar_Content_Regular = st.selectbox("Product Sugar Content Regular", [0, 1])
Product_Sugar_Content_reg = st.selectbox("Product Sugar Content reg", [0, 1])
Product_Type_Breads = st.selectbox("Product Type Breads", [0, 1])
Product_Type_Breakfast = st.selectbox("Product Type Breakfast", [0, 1])
Product_Type_Canned = st.selectbox("Product Type Canned", [0, 1])
Product_Type_Dairy = st.selectbox("Product Type Dairy", [0, 1])
Product_Type_Frozen_Foods = st.selectbox("Product Type Frozen Foods", [0, 1])
Product_Type_Fruits_and_Vegetables = st.selectbox("Product Type Fruits and Vegetables", [0, 1])
Product_Type_Hard_Drinks = st.selectbox("Product Type Hard Drinks", [0, 1])
Product_Type_Health_and_Hygiene = st.selectbox("Product Type Health and Hygiene", [0, 1])
Product_Type_Household = st.selectbox("Product Type Household", [0, 1])
Product_Type_Meat = st.selectbox("Product Type Meat", [0, 1])
Product_Type_Others = st.selectbox("Product Type Others", [0, 1])
Product_Type_Seafood = st.selectbox("Product Type Seafood", [0, 1])
Product_Type_Snack_Foods = st.selectbox("Product Type Snack Foods", [0, 1])
Product_Type_Soft_Drinks = st.selectbox("Product Type Soft Drinks", [0, 1])
Product_Type_Starchy_Foods = st.selectbox("Product Type Starchy Foods", [0, 1])
Store_Size_Medium = st.selectbox("Store Size Medium", [0, 1])
Store_Size_Small = st.selectbox("Store Size Small", [0, 1])
Store_Location_City_Type_Tier_2 = st.selectbox("Store Location City Type Tier 2", [0, 1])
Store_Location_City_Type_Tier_3 = st.selectbox("Store Location City Type Tier 3", [0, 1])
Store_Type_Food_Mart = st.selectbox("Store Type Food Mart", [0, 1])
Store_Type_Supermarket_Type1 = st.selectbox("Store Type Supermarket Type1", [0, 1])
Store_Type_Supermarket_Type2 = st.selectbox("Store Type Supermarket Type2", [0, 1])

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
    'Product_Weight': Product_Weight,
    'Product_Allocated_Area': Product_Allocated_Area,
    'Product_MRP': Product_MRP,
    'Store_Establishment_Year': Store_Establishment_Year,
    'Product_Sugar_Content_No Sugar': Product_Sugar_Content_No_Sugar,
    'Product_Sugar_Content_Regular': Product_Sugar_Content_Regular,
    'Product_Sugar_Content_reg': Product_Sugar_Content_reg,
    'Product_Type_Breads': Product_Type_Breads,
    'Product_Type_Breakfast': Product_Type_Breakfast,
    'Product_Type_Canned': Product_Type_Canned,
    'Product_Type_Dairy': Product_Type_Dairy,
    'Product_Type_Frozen Foods': Product_Type_Frozen_Foods,
    'Product_Type_Fruits and Vegetables': Product_Type_Fruits_and_Vegetables,
    'Product_Type_Hard Drinks': Product_Type_Hard_Drinks,
    'Product_Type_Health and Hygiene': Product_Type_Health_and_Hygiene,
    'Product_Type_Household': Product_Type_Household,
    'Product_Type_Meat': Product_Type_Meat,
    'Product_Type_Others': Product_Type_Others,
    'Product_Type_Seafood': Product_Type_Seafood,
    'Product_Type_Snack Foods': Product_Type_Snack_Foods,
    'Product_Type_Soft Drinks': Product_Type_Soft_Drinks,
    'Product_Type_Starchy Foods': Product_Type_Starchy_Foods,
    'Store_Size_Medium': Store_Size_Medium,
    'Store_Size_Small': Store_Size_Small,
    'Store_Location_City_Type_Tier 2': Store_Location_City_Type_Tier_2,
    'Store_Location_City_Type_Tier 3': Store_Location_City_Type_Tier_3,
    'Store_Type_Food Mart': Store_Type_Food_Mart,
    'Store_Type_Supermarket Type1': Store_Type_Supermarket_Type1,
    'Store_Type_Supermarket Type2': Store_Type_Supermarket_Type2
}])


https://huggingface.co/spaces/nlauchande/ForecastBackend/v1/predict

# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
    response = requests.post("https://nlauchande-nlauchande/ForecastBackend.hf.space/v1/predict", json=input_data.to_dict(orient='records')[0])  # Send data to Flask API
    if response.status_code == 200:
        prediction = response.json()['Predicted Sales']
        st.success(f"Predicted Sales: {prediction}")
    else:
        st.error("Error making prediction.")