Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +32 -14
streamlit_app.py
CHANGED
|
@@ -11,9 +11,13 @@ BACKEND_URL = "https://dhani10-SuperKart-Backend.hf.space/predict"
|
|
| 11 |
@st.cache_data
|
| 12 |
def load_dropdown_data():
|
| 13 |
df = pd.read_csv("SuperKart.csv")
|
| 14 |
-
product_ids = sorted(df['Product_Id'].dropna().unique())
|
| 15 |
-
store_ids = sorted(df['Store_Id'].dropna().unique())
|
| 16 |
-
years = sorted(df['Store_Establishment_Year'].dropna().unique())
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
return product_ids, store_ids, years, df
|
| 18 |
|
| 19 |
# Page Title
|
|
@@ -52,20 +56,34 @@ with st.form("prediction_form"):
|
|
| 52 |
|
| 53 |
# Prediction logic
|
| 54 |
if submit:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
data = {
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
}
|
| 68 |
|
|
|
|
| 69 |
try:
|
| 70 |
response = requests.post(BACKEND_URL, json=data)
|
| 71 |
if response.status_code == 200:
|
|
|
|
| 11 |
@st.cache_data
|
| 12 |
def load_dropdown_data():
|
| 13 |
df = pd.read_csv("SuperKart.csv")
|
| 14 |
+
# product_ids = sorted(df['Product_Id'].dropna().unique())
|
| 15 |
+
# store_ids = sorted(df['Store_Id'].dropna().unique())
|
| 16 |
+
# years = sorted(df['Store_Establishment_Year'].dropna().unique())
|
| 17 |
+
product_ids = sorted(df['Product_Id'].dropna().astype(str).unique())
|
| 18 |
+
store_ids = sorted(df['Store_Id'].dropna().astype(str).unique())
|
| 19 |
+
years = sorted(df['Store_Establishment_Year'].dropna().astype(int).unique())
|
| 20 |
+
|
| 21 |
return product_ids, store_ids, years, df
|
| 22 |
|
| 23 |
# Page Title
|
|
|
|
| 56 |
|
| 57 |
# Prediction logic
|
| 58 |
if submit:
|
| 59 |
+
# data = {
|
| 60 |
+
# "Product_Id": product_id,
|
| 61 |
+
# "Product_Weight": product_weight,
|
| 62 |
+
# "Product_Sugar_Content": sugar_content,
|
| 63 |
+
# "Product_Allocated_Area": allocated_area,
|
| 64 |
+
# "Product_Type": product_type,
|
| 65 |
+
# "Product_MRP": mrp,
|
| 66 |
+
# "Store_Id": store_id,
|
| 67 |
+
# "Store_Establishment_Year": establishment_year,
|
| 68 |
+
# "Store_Size": store_size,
|
| 69 |
+
# "Store_Location_City_Type": city_type,
|
| 70 |
+
# "Store_Type": store_type
|
| 71 |
+
# }
|
| 72 |
data = {
|
| 73 |
+
"Product_Id": str(product_id),
|
| 74 |
+
"Product_Weight": float(product_weight),
|
| 75 |
+
"Product_Sugar_Content": str(sugar_content),
|
| 76 |
+
"Product_Allocated_Area": float(allocated_area),
|
| 77 |
+
"Product_Type": str(product_type),
|
| 78 |
+
"Product_MRP": float(mrp),
|
| 79 |
+
"Store_Id": str(store_id),
|
| 80 |
+
"Store_Establishment_Year": int(establishment_year), # FIXED LINE
|
| 81 |
+
"Store_Size": str(store_size),
|
| 82 |
+
"Store_Location_City_Type": str(city_type),
|
| 83 |
+
"Store_Type": str(store_type)
|
| 84 |
}
|
| 85 |
|
| 86 |
+
|
| 87 |
try:
|
| 88 |
response = requests.post(BACKEND_URL, json=data)
|
| 89 |
if response.status_code == 200:
|