Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,36 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
import requests
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
-
|
| 6 |
-
BACKEND_URL = "https://AkhilRaja-superkart-flask-api.hf.space/predict"
|
| 7 |
-
|
| 8 |
-
st.set_page_config(page_title="SuperKart Predictor", page_icon="π", layout="wide")
|
| 9 |
|
| 10 |
-
|
| 11 |
-
st.
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if st.button("Predict"):
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
"
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
st.success(f"β
Prediction: {result['predictions']}")
|
| 32 |
-
else:
|
| 33 |
-
st.error(f"β Error: {response.text}")
|
| 34 |
-
except Exception as e:
|
| 35 |
-
st.error(f"π¨ Failed to connect to backend: {e}")
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
+
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
+
st.title("π SuperKart Sales Predictor")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Collect inputs
|
| 8 |
+
Product_Weight = st.number_input("Product Weight", 0.0, 50.0, 12.5)
|
| 9 |
+
Product_Sugar_Content = st.selectbox("Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 10 |
+
Product_Allocated_Area = st.number_input("Allocated Area", 0.0, 1.0, 0.25)
|
| 11 |
+
Product_Type = st.text_input("Product Type", "Snack foods")
|
| 12 |
+
Product_MRP = st.number_input("MRP", 0.0, 500.0, 200.0)
|
| 13 |
+
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 14 |
+
Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 15 |
+
Store_Type = st.text_input("Store Type", "Supermarket Type1")
|
| 16 |
|
| 17 |
if st.button("Predict"):
|
| 18 |
+
sample = [{
|
| 19 |
+
"Product_Weight": Product_Weight,
|
| 20 |
+
"Product_Sugar_Content": Product_Sugar_Content,
|
| 21 |
+
"Product_Allocated_Area": Product_Allocated_Area,
|
| 22 |
+
"Product_Type": Product_Type,
|
| 23 |
+
"Product_MRP": Product_MRP,
|
| 24 |
+
"Store_Size": Store_Size,
|
| 25 |
+
"Store_Location_City_Type": Store_Location_City_Type,
|
| 26 |
+
"Store_Type": Store_Type
|
| 27 |
+
}]
|
| 28 |
+
|
| 29 |
+
url = "https://akhilraja-superkart-flask-api.hf.space/predict"
|
| 30 |
+
response = requests.post(url, json=sample)
|
| 31 |
|
| 32 |
+
if response.status_code == 200:
|
| 33 |
+
result = response.json()
|
| 34 |
+
st.success(f"Predicted Sales: {result['predictions'][0]:.2f}")
|
| 35 |
+
else:
|
| 36 |
+
st.error(f"Error: {response.text}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|