Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +42 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
API_URL = "https://Hunagypsy-superkart-backend-api.hf.space/v1/predict"
|
| 5 |
+
|
| 6 |
+
st.title("Product Store Sales Prediction App")
|
| 7 |
+
|
| 8 |
+
# User Inputs
|
| 9 |
+
Product_Weight = st.number_input("Product Weight", min_value=0.0, value=12.66)
|
| 10 |
+
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 11 |
+
Product_Allocated_Area = st.selectbox("Product Allocated Area", ["Small", "Medium", "Large"])
|
| 12 |
+
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
|
| 13 |
+
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 14 |
+
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 15 |
+
Store_Type = st.selectbox("Store Type", ["Type 1", "Type 2", "Type 3", "Type 4"])
|
| 16 |
+
Product_Id_char = st.text_input("Product ID (char)", value="FDX")
|
| 17 |
+
Store_Age_Years = st.number_input("Store Age (Years)", min_value=0, value=5)
|
| 18 |
+
Product_Type_Category = st.selectbox("Product Type Category", ["Food", "Non-Food", "Drinks"])
|
| 19 |
+
|
| 20 |
+
product_data = {
|
| 21 |
+
"Product_Weight": Product_Weight,
|
| 22 |
+
"Product_Sugar_Content": Product_Sugar_Content,
|
| 23 |
+
"Product_Allocated_Area": Product_Allocated_Area,
|
| 24 |
+
"Product_MRP": Product_MRP,
|
| 25 |
+
"Store_Size": Store_Size,
|
| 26 |
+
"Store_Location_City_Type": Store_Location_City_Type,
|
| 27 |
+
"Store_Type": Store_Type,
|
| 28 |
+
"Product_Id_char": Product_Id_char,
|
| 29 |
+
"Store_Age_Years": Store_Age_Years,
|
| 30 |
+
"Product_Type_Category": Product_Type_Category
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
if st.button("Predict"):
|
| 34 |
+
try:
|
| 35 |
+
response = requests.post(API_URL, json=product_data)
|
| 36 |
+
if response.status_code == 200:
|
| 37 |
+
result = response.json()
|
| 38 |
+
st.success(f"Predicted Product Store Sales Total: ₹{{result['Sales']:.2f}}")
|
| 39 |
+
else:
|
| 40 |
+
st.error(f"API request failed: {{response.status_code}}")
|
| 41 |
+
except Exception as e:
|
| 42 |
+
st.error(f"Error: {{e}}")
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.45.0
|
| 2 |
+
requests==2.32.3
|