File size: 1,844 Bytes
5484f7e
 
 
 
 
923bd6b
5484f7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5c6a9c
 
5484f7e
 
 
 
 
 
 
e6bd86c
5484f7e
 
 
 
 
 
 
 
 
d5c6a9c
5484f7e
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
import streamlit as st
import pandas as pd
import requests

# Load trained model
#model = joblib.load("best_model.joblib")

st.set_page_config(page_title="SuperKart Sales Predictor", page_icon="๐Ÿ›’")

st.title("๐Ÿ›’ SuperKart Sales Prediction App")

st.write("Enter product and store details to predict expected sales.")

# Collect inputs from user
product_mrp = st.number_input("Product MRP", min_value=0.0, max_value=10000.0, step=1.0)
store_type = st.selectbox("Store Type", ["Supermarket", "Grocery", "Online", "Other"])
store_size = st.selectbox("Store Size", ["Small", "Medium", "Large"])
sugar_content = st.selectbox("Sugar Content", ["Low", "Medium", "High"])

# Create input dataframe
input_df = pd.DataFrame([{
        "Product_MRP": product_mrp,
        "Store_Type": store_type,
        "Store_Size": store_size,
        "Sugar_Content": sugar_content
}])

# Predict button
if st.button("Predict Sales"):
    Response = requests.post("https://kedhar4-superKart.hf.space/v1/kartperdiction", json=input_df.to_dict(orient="records")[0])
    if Response.status_code == 200:
        prediction = Response.json()["prediction"]
        st.success(f"Predicted Sales: {prediction}")
    else:
        st.error("Error in prediction")


# section for batch prediction
st. subheader("Batch Prediction")
file_upload = st.file_uploader("Upload Excel file for batch prediction", type=["xls", "xlsx"])

if file_upload is not None:
    file_details = {"file": file_upload.getvalue()}

    response = requests.post("https://kedhar4-superKart.hf.space/v1/predict_batch", files=file_details)

    if response.status_code == 200:
        prediictions = response.json()
        st.json(prediictions)
        st.success("Batch prediction completed successfully!")
        st.write(prediictions)
    else:
        st.error("Error in batch prediction")