File size: 3,310 Bytes
e9c1294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
df9ec78
e9c1294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2ee007
e9c1294
 
df9ec78
e9c1294
 
 
df9ec78
e9c1294
 
 
df9ec78
e9c1294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c808fa
e9c1294
f9a4ed6
 
 
3421806
 
e9c1294
 
 
 
 
 
 
 
 
 
 
 
3c808fa
e9c1294
 
 
 
 
 
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import streamlit as st
import pandas as pd
import requests

# Set the title of the Streamlit app
st.title("SuperKart's Deceison Making Model")

# Section for online prediction
st.subheader("Online SuperKart's Model")

# Collect user input for property features
# Product features
product_weight = st.number_input("Product Weight (in grams)", min_value=0.0, step=0.1)
product_sugar_content = st.selectbox(
    "Product Sugar Content",
    ["Low Sugar", "Regular", "No Sugar"]
)
product_allocated_area = st.number_input(
    "Producted Allocated Area (sq. ft.)", min_value=0.01, step=0.01, value=0.01
)
product_type = st.selectbox(
    "Product Type",
    [
        "Meat",
        "Snack Foods",
        "Hard Drinks",
        "Dairy",
        "Canned",
        "Soft Drinks",
        "Health and Hygiene",
        "Baking Goods",
        "Bread",
        "Breakfast",
        "Frozen Foods",
        "Fruits and Vegetables",
        "Household",
        "Seafood",
        "Starchy Foods",
        "Others"
    ]
)

product_mrp = st.number_input(
    "Product MRP (in dollars)", min_value=1.0, step=0.5, value=10.0
)

store_size = st.selectbox(
    "Store Size",
    ["Low", "Medium", "High"]
)
store_location_city_type = st.selectbox(
    "Store Location City Type",
    ["Tier 1", "Tier 2", "Tier 3"]
)
store_type = st.selectbox(
    "Store Type",
    ["Departmental Store", "Food Mart", "Supermarket Type1", "Supermarket Type2"]
)

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
    '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_size': store_size,
    'store_location_city_type': store_location_city_type,
    'store_type':store_type
}])

# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
    print(input_data.to_dict(orient='records')[0])
    # Send the input data to the Flask API for prediction
    response = requests.post("https://anithajk-SuperKartDecesionMakingModelBackend.hf.space/v1/productsale", json=input_data.to_dict(orient='records')[0])  # Send data to Flask API
    if response.status_code == 200:
        print(f"result {response.json()}")
        data = response.json()
        print(data.keys())
        prediction = response.json()['Total Revenue (in dollars)']
        st.success(f"Total Revenue (in dollars): {prediction}")
    else:
        st.error("Error making prediction.")

# Section for batch prediction
st.subheader("Batch Prediction")

# Allow users to upload a CSV file for batch prediction
uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"])

# Make batch prediction when the "Predict Batch" button is clicked
if uploaded_file is not None:
    if st.button("Predict Batch"):
        response = requests.post("https://anithajk-SuperKartDecesionMakingModelBackend.hf.space/v1/productsalebatch", files={"file": uploaded_file})  # Send file to Flask API
        if response.status_code == 200:
            predictions = response.json()
            st.success("Batch predictions completed!")
            st.write(predictions)  # Display the predictions
        else:
            st.error("Error making batch prediction.")