| |
|
| | import streamlit as st |
| | import pandas as pd |
| | import joblib |
| | import numpy as np |
| |
|
| | |
| | @st.cache_resource |
| | def load_model(): |
| | return joblib.load("superkart_sales_prediction_model_v1_0.joblib") |
| |
|
| | model = load_model() |
| |
|
| | |
| | st.title("SuperKart Product Store Sales Prediction App") |
| | st.write("This app predicts the Total revenue generated by the sale of a particular product in a particular store.") |
| |
|
| | st.subheader("Enter the product and store details:") |
| |
|
| | |
| | product_weight = st.number_input("Product Weight", min_value=4.0, max_value=22.0, value=12.0) |
| | product_allocated_area = st.number_input("Product Allocated Area", min_value=0.004, max_value=0.298, value=0.05) |
| | product_mrp = st.number_input("Product MRP", min_value=31.0, max_value=266.0, value=150.0) |
| | store_age = st.number_input("Store Age", min_value=16, max_value=38, value=20) |
| |
|
| | product_identifier = st.selectbox("Product Identifier", ["FD", "NC", "DR"]) |
| | product_sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"]) |
| | store_id = st.selectbox("Store ID", ['OUT002', 'OUT003', 'OUT004', 'OUT010', 'OUT013', 'OUT017', 'OUT018', 'OUT019', 'OUT027']) |
| | store_size = st.selectbox("Store Size", ["High", "Medium", "Small"]) |
| | store_location_city_type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"]) |
| | store_type = st.selectbox("Store Type", ["Departmental Store", "Supermarket Type1", "Supermarket Type2", "Food Mart"]) |
| |
|
| |
|
| | |
| | user_input_data = { |
| | 'Product_Weight': product_weight, |
| | 'Product_Allocated_Area': product_allocated_area, |
| | 'Product_MRP': product_mrp, |
| | 'Store_Age': store_age, |
| | 'Product_Identifier': product_identifier, |
| | 'Product_Sugar_Content_No Sugar': product_sugar_content == 'No Sugar', |
| | 'Product_Sugar_Content_Regular': product_sugar_content == 'Regular', |
| | 'Product_Sugar_Content_reg': product_sugar_content == 'reg', |
| | 'Product_Type_Breads': False, |
| | 'Product_Type_Breakfast': False, |
| | 'Product_Type_Canned': False, |
| | 'Product_Type_Dairy': False, |
| | 'Product_Type_Frozen Foods': False, |
| | 'Product_Type_Fruits and Vegetables': False, |
| | 'Product_Type_Hard Drinks': False, |
| | 'Product_Type_Health and Hygiene': False, |
| | 'Product_Type_Household': False, |
| | 'Product_Type_Meat': False, |
| | 'Product_Type_Others': False, |
| | 'Product_Type_Seafood': False, |
| | 'Product_Type_Snack Foods': False, |
| | 'Product_Type_Soft Drinks': False, |
| | 'Product_Type_Starchy Foods': False, |
| | 'Store_Id_OUT002': store_id == 'OUT002', |
| | 'Store_Id_OUT003': store_id == 'OUT003', |
| | 'Store_Id_OUT004': store_id == 'OUT004', |
| | 'Store_Id_OUT010': store_id == 'OUT010', |
| | 'Store_Id_OUT013': store_id == 'OUT013', |
| | 'Store_Id_OUT017': store_id == 'OUT017', |
| | 'Store_Id_OUT018': store_id == 'OUT018', |
| | 'Store_Id_OUT019': store_id == 'OUT019', |
| | 'Store_Id_OUT027': store_id == 'OUT027', |
| | 'Store_Size_Medium': store_size == 'Medium', |
| | 'Store_Size_Small': store_size == 'Small', |
| | 'Store_Location_City_Type_Tier 2': store_location_city_type == 'Tier 2', |
| | 'Store_Location_City_Type_Tier 3': store_location_city_type == 'Tier 3', |
| | 'Store_Type_Food Mart': store_type == 'Food Mart', |
| | 'Store_Type_Supermarket Type1': store_type == 'Supermarket Type1', |
| | 'Store_Type_Supermarket Type2': store_type == 'Supermarket Type2' |
| | } |
| |
|
| | |
| | input_data_df = pd.DataFrame([user_input_data]) |
| |
|
| | |
| | |
| |
|
| | |
| | if st.button("Predict"): |
| | |
| | prediction = model.predict(input_data_df) |
| |
|
| | |
| | st.write(f"The predicted Product Store Sales Total is: {prediction[0]:.2f}") |
| |
|