Spaces:
No application file
No application file
Update
Browse files
app.py
CHANGED
|
@@ -1,28 +1,44 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
# Load
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
st.title("SuperKart Sales Revenue Predictor")
|
| 6 |
+
|
| 7 |
+
# Load model
|
| 8 |
+
@st.cache_resource
|
| 9 |
+
def load_model():
|
| 10 |
+
return joblib.load('final_rf_model.pkl')
|
| 11 |
+
|
| 12 |
+
model = load_model()
|
| 13 |
+
|
| 14 |
+
# Define all input fields
|
| 15 |
+
st.header("Enter Product & Store Details:")
|
| 16 |
+
product_weight = st.number_input("Product Weight", min_value=0.0, max_value=50.0, value=12.5)
|
| 17 |
+
product_sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "High"])
|
| 18 |
+
product_allocated_area = st.number_input("Product Allocated Area", min_value=0.0, max_value=1.0, value=0.05)
|
| 19 |
+
product_type = st.selectbox("Product Type", [
|
| 20 |
+
"Fruits and Vegetables", "Snack Foods", "Household", "Dairy", "Baking Goods",
|
| 21 |
+
"Frozen Foods", "Canned", "Soft Drinks", "Breads", "Breakfast", "Health and Hygiene",
|
| 22 |
+
"Meat", "Others", "Seafood", "Starchy Foods", "Hard Drinks"
|
| 23 |
+
])
|
| 24 |
+
product_mrp = st.number_input("Product MRP", min_value=0.0, max_value=300.0, value=150.0)
|
| 25 |
+
store_establishment_year = st.selectbox("Store Establishment Year", list(range(1987, 2010)))
|
| 26 |
+
store_size = st.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 27 |
+
store_location_city_type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 28 |
+
store_type = st.selectbox("Store Type", ["Supermarket Type2", "Supermarket Type1", "Departmental Store", "Food Mart"])
|
| 29 |
+
|
| 30 |
+
# Predict button
|
| 31 |
+
if st.button("Predict Sales"):
|
| 32 |
+
input_df = pd.DataFrame([{
|
| 33 |
+
"Product_Weight": product_weight,
|
| 34 |
+
"Product_Sugar_Content": product_sugar_content,
|
| 35 |
+
"Product_Allocated_Area": product_allocated_area,
|
| 36 |
+
"Product_Type": product_type,
|
| 37 |
+
"Product_MRP": product_mrp,
|
| 38 |
+
"Store_Establishment_Year": store_establishment_year,
|
| 39 |
+
"Store_Size": store_size,
|
| 40 |
+
"Store_Location_City_Type": store_location_city_type,
|
| 41 |
+
"Store_Type": store_type
|
| 42 |
+
}])
|
| 43 |
+
prediction = model.predict(input_df)[0]
|
| 44 |
+
st.success(f"Predicted Quarterly Sales Revenue: ₹ {prediction:,.2f}")
|