Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,56 @@
|
|
| 1 |
-
import joblib
|
| 2 |
-
import pandas as pd
|
| 3 |
import streamlit as st
|
|
|
|
|
|
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
model = joblib.load(model_path)
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
|
| 6 |
+
st.set_page_config(page_title="SuperKart Sales Predictor", layout="centered")
|
| 7 |
+
st.title("SuperKart Sales Prediction")
|
| 8 |
+
st.write("Predict **Product_Store_Sales_Total** using the trained SuperKart model hosted on Hugging Face.")
|
| 9 |
+
|
| 10 |
+
MODEL_REPO = "atsh2846/superkart_model"
|
| 11 |
+
MODEL_FILE = "superkart_model.joblib"
|
| 12 |
+
|
| 13 |
+
@st.cache_resource
|
| 14 |
+
def load_model():
|
| 15 |
+
model_path = hf_hub_download(
|
| 16 |
+
repo_id=MODEL_REPO,
|
| 17 |
+
filename=MODEL_FILE,
|
| 18 |
+
repo_type="model"
|
| 19 |
+
)
|
| 20 |
+
return joblib.load(model_path)
|
| 21 |
|
| 22 |
+
model = load_model()
|
| 23 |
|
| 24 |
+
st.subheader("Enter product & store details")
|
|
|
|
| 25 |
|
| 26 |
+
# Inputs (match your dataset columns)
|
| 27 |
+
Product_Id = st.text_input("Product_Id", value="NC6218")
|
| 28 |
+
Product_Weight = st.number_input("Product_Weight", value=10.0)
|
| 29 |
+
Product_Sugar_Content = st.selectbox("Product_Sugar_Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 30 |
+
Product_Allocated_Area = st.number_input("Product_Allocated_Area", value=1200.0)
|
| 31 |
+
Product_Type = st.text_input("Product_Type", value="Snack Foods")
|
| 32 |
+
Product_MRP = st.number_input("Product_MRP", value=150.0)
|
| 33 |
|
| 34 |
+
Store_Id = st.text_input("Store_Id", value="OUT049")
|
| 35 |
+
Store_Establishment_Year = st.number_input("Store_Establishment_Year", value=2005)
|
| 36 |
+
Store_Size = st.selectbox("Store_Size", ["Small", "Medium", "High"])
|
| 37 |
+
Store_Location_City_Type = st.selectbox("Store_Location_City_Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 38 |
+
Store_Type = st.selectbox("Store_Type", ["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"])
|
| 39 |
|
| 40 |
+
if st.button("Predict Sales"):
|
| 41 |
+
row = {
|
| 42 |
+
"Product_Id": Product_Id,
|
| 43 |
+
"Product_Weight": Product_Weight,
|
| 44 |
+
"Product_Sugar_Content": Product_Sugar_Content,
|
| 45 |
+
"Product_Allocated_Area": Product_Allocated_Area,
|
| 46 |
+
"Product_Type": Product_Type,
|
| 47 |
+
"Product_MRP": Product_MRP,
|
| 48 |
+
"Store_Id": Store_Id,
|
| 49 |
+
"Store_Establishment_Year": Store_Establishment_Year,
|
| 50 |
+
"Store_Size": Store_Size,
|
| 51 |
+
"Store_Location_City_Type": Store_Location_City_Type,
|
| 52 |
+
"Store_Type": Store_Type,
|
| 53 |
+
}
|
| 54 |
+
X = pd.DataFrame([row])
|
| 55 |
+
pred = model.predict(X)[0]
|
| 56 |
+
st.success(f"Predicted Product_Store_Sales_Total: {pred:.2f}")
|