Spaces:
Runtime error
Runtime error
Commit Β·
d877c89
1
Parent(s): b6ced55
Updated app.py
Browse files- Dockerfile +1 -1
- app.py +0 -35
- deployment/app.py +1 -1
- predict.py +0 -23
Dockerfile
CHANGED
|
@@ -10,4 +10,4 @@ COPY . .
|
|
| 10 |
ENV HF_MODEL_REPO="manoj112025/SuperKartSalesModel"
|
| 11 |
EXPOSE 7860
|
| 12 |
|
| 13 |
-
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
|
| 10 |
ENV HF_MODEL_REPO="manoj112025/SuperKartSalesModel"
|
| 11 |
EXPOSE 7860
|
| 12 |
|
| 13 |
+
CMD ["streamlit", "run", "deployment/app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
app.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
from predict import predict_one
|
| 4 |
-
|
| 5 |
-
st.set_page_config(page_title="SuperKart Sales Predictor", page_icon="π", layout="centered")
|
| 6 |
-
st.title("π SuperKart Sales Prediction App")
|
| 7 |
-
|
| 8 |
-
st.markdown("Enter product & store details to predict **Product_Store_Sales_Total**")
|
| 9 |
-
|
| 10 |
-
# Input UI
|
| 11 |
-
inputs = {
|
| 12 |
-
"Product_Weight": st.number_input("Product Weight", min_value=0.0, value=12.0, step=0.1),
|
| 13 |
-
"Product_Sugar_Content": st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"]),
|
| 14 |
-
"Product_Allocated_Area": st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.05),
|
| 15 |
-
"Product_Type": st.selectbox("Product Type", [
|
| 16 |
-
"Frozen Foods", "Dairy", "Canned", "Baking Goods", "Health and Hygiene", "Snack Foods",
|
| 17 |
-
"Meat", "Household", "Hard Drinks", "Fruits and Vegetables", "Breads",
|
| 18 |
-
"Breakfast", "Seafood", "Starchy Foods", "Soft Drinks", "Others",
|
| 19 |
-
"Food Mart", "Departmental Store", "Supermarket Type1", "Supermarket Type2"
|
| 20 |
-
]),
|
| 21 |
-
"Product_MRP": st.number_input("Product MRP", min_value=0.0, value=150.0),
|
| 22 |
-
"Store_Id": st.selectbox("Store ID", ["OUT001", "OUT002", "OUT003", "OUT004"]),
|
| 23 |
-
"Store_Establishment_Year": st.number_input("Store Establishment Year", value=2000, step=1),
|
| 24 |
-
"Store_Size": st.selectbox("Store Size", ["Small", "Medium", "High"]),
|
| 25 |
-
"Store_Location_City_Type": st.selectbox("Store City Type", ["Tier 1", "Tier 2", "Tier 3"]),
|
| 26 |
-
"Store_Type": st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"])
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
if st.button("Predict Sales"):
|
| 30 |
-
df = pd.DataFrame([inputs])
|
| 31 |
-
try:
|
| 32 |
-
prediction = predict_one(df)
|
| 33 |
-
st.success(f"Predicted Sales: **{float(prediction[0]):,.2f}**")
|
| 34 |
-
except Exception as e:
|
| 35 |
-
st.error(f"Prediction Failed: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deployment/app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
from predict import predict_one
|
| 4 |
|
| 5 |
st.set_page_config(page_title="SuperKart Sales Predictor", page_icon="π", layout="centered")
|
| 6 |
st.title("π SuperKart Sales Prediction App")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
from deployment.predict import predict_one
|
| 4 |
|
| 5 |
st.set_page_config(page_title="SuperKart Sales Predictor", page_icon="π", layout="centered")
|
| 6 |
st.title("π SuperKart Sales Prediction App")
|
predict.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import joblib
|
| 3 |
-
import pandas as pd
|
| 4 |
-
from huggingface_hub import hf_hub_download
|
| 5 |
-
|
| 6 |
-
MODEL_REPO = os.getenv("HF_MODEL_REPO", "manoj112025/SuperKartSalesModel")
|
| 7 |
-
MODEL_FILE = "model.joblib"
|
| 8 |
-
PREPROCESSOR_FILE = "preprocessor.joblib"
|
| 9 |
-
|
| 10 |
-
def load_artifacts():
|
| 11 |
-
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE, repo_type="model")
|
| 12 |
-
pre_path = hf_hub_download(repo_id=MODEL_REPO, filename=PREPROCESSOR_FILE, repo_type="model")
|
| 13 |
-
|
| 14 |
-
model = joblib.load(model_path)
|
| 15 |
-
preprocessor = joblib.load(pre_path)
|
| 16 |
-
|
| 17 |
-
return preprocessor, model
|
| 18 |
-
|
| 19 |
-
def predict_one(df: pd.DataFrame):
|
| 20 |
-
preprocessor, model = load_artifacts()
|
| 21 |
-
X = preprocessor.transform(df)
|
| 22 |
-
y = model.predict(X)
|
| 23 |
-
return y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|