Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -20,19 +20,42 @@ Store_Type = st.selectbox("Store Type", ["Supermarket Type2","Departmental Store
|
|
| 20 |
Product_Weight = st.number_input("Product Weight", min_value=4.0, max_value=22.0)
|
| 21 |
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar","Regular","No Sugar"])
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
|
|
|
| 25 |
'Product_Allocated_Area': Product_Allocated_Area,
|
| 26 |
-
'Product_Group': Product_Group,
|
| 27 |
'Product_MRP': Product_MRP,
|
| 28 |
-
'
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
'
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Make prediction when the "Predict" button is clicked
|
| 38 |
if st.button("Predict"):
|
|
|
|
| 20 |
Product_Weight = st.number_input("Product Weight", min_value=4.0, max_value=22.0)
|
| 21 |
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar","Regular","No Sugar"])
|
| 22 |
|
| 23 |
+
# Start with numerical features dictionary
|
| 24 |
+
features_dict = {
|
| 25 |
+
'Product_Weight': Product_Weight,
|
| 26 |
'Product_Allocated_Area': Product_Allocated_Area,
|
|
|
|
| 27 |
'Product_MRP': Product_MRP,
|
| 28 |
+
'Store_Age': Store_Age
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
# Manual one-hot encoding for categorical features as per after-encoding columns order
|
| 32 |
+
# Product_Sugar_Content
|
| 33 |
+
for cat in ["Low Sugar", "No Sugar", "Regular"]:
|
| 34 |
+
features_dict[f'Product_Sugar_Content_{cat}'] = int(Product_Sugar_Content == cat)
|
| 35 |
+
|
| 36 |
+
# Store_Id
|
| 37 |
+
for cat in ["OUT001","OUT002","OUT003","OUT004"]:
|
| 38 |
+
features_dict[f'Store_Id_{cat}'] = int(Store_Id == cat)
|
| 39 |
+
|
| 40 |
+
# Store_Size
|
| 41 |
+
for cat in ["High", "Medium", "Small"]:
|
| 42 |
+
features_dict[f'Store_Size_{cat}'] = int(Store_Size == cat)
|
| 43 |
+
|
| 44 |
+
# Store_Location_City_Type
|
| 45 |
+
for cat in ["Tier 1", "Tier 2", "Tier 3"]:
|
| 46 |
+
features_dict[f'Store_Location_City_Type_{cat}'] = int(Store_Location_City_Type == cat)
|
| 47 |
+
|
| 48 |
+
# Store_Type
|
| 49 |
+
for cat in ["Departmental Store","Food Mart","Supermarket Type1","Supermarket Type2"]:
|
| 50 |
+
features_dict[f'Store_Type_{cat}'] = int(Store_Type == cat)
|
| 51 |
+
|
| 52 |
+
# Product_Group
|
| 53 |
+
for cat in ["Non-Food/Household","Packaged/Processed Foods","Perishable Foods"]:
|
| 54 |
+
features_dict[f'Product_Group_{cat}'] = int(Product_Group == cat)
|
| 55 |
+
|
| 56 |
+
# Create DataFrame with matching columns
|
| 57 |
+
input_data = pd.DataFrame([features_dict])
|
| 58 |
+
|
| 59 |
|
| 60 |
# Make prediction when the "Predict" button is clicked
|
| 61 |
if st.button("Predict"):
|