mkrish2025 commited on
Commit
be03d0a
·
verified ·
1 Parent(s): 9dadef2

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +34 -11
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
- # Convert user input into a DataFrame
24
- input_data = pd.DataFrame([{
 
25
  'Product_Allocated_Area': Product_Allocated_Area,
26
- 'Product_Group': Product_Group,
27
  'Product_MRP': Product_MRP,
28
- 'Store_Id': Store_Id,
29
- 'Store_Age': Store_Age,
30
- 'Store_Size': Store_Size,
31
- 'Store_Location_City_Type': Store_Location_City_Type,
32
- 'Store_Type': Store_Type,
33
- 'Product_Weight': Product_Weight,
34
- 'Product_Sugar_Content': Product_Sugar_Content
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"):