| import streamlit as st |
| import pandas as pd |
| import joblib |
| import numpy as np |
| import joblib |
| import xgboost |
| import sklearn |
|
|
| |
| @st.cache_resource |
| def load_model(): |
| return joblib.load("Superkart_sales_model_v1_0.joblib") |
|
|
| model = load_model() |
|
|
|
|
| |
| |
| st.title("SuperKart Sales Prediction App - By Sriranjan") |
| st.write("Input the product and store details below. The app will predict the **Product Store Sales Total** using the trained ML model.") |
|
|
| st.subheader("Enter the listing details:") |
|
|
| |
| |
| product_sugar_content_options = ['Low Sugar', 'Regular', 'No Sugar', 'reg'] |
| product_type_options = [ |
| 'Fruits and Vegetables', 'Snack Foods', 'Frozen Foods', 'Dairy', 'Household', |
| 'Baking Goods', 'Canned', 'Health and Hygiene', 'Meat', 'Soft Drinks', |
| 'Breads', 'Hard Drinks', 'Others', 'Starchy Foods', 'Breakfast', 'Seafood' |
| ] |
| store_id_options = ['OUT004', 'OUT001', 'OUT003', 'OUT002'] |
| store_size_options = ['Medium', 'High', 'Small'] |
| city_type_options = ['Tier 2', 'Tier 1', 'Tier 3'] |
| store_type_options = ['Supermarket Type2', 'Supermarket Type1', 'Departmental Store', 'Food Mart'] |
|
|
| |
|
|
| |
| |
| product_weight = st.number_input("Product Weight (kg)",min_value=4.0,max_value=22.0, value=4.0,help="Weight of the product in kilograms") |
|
|
| product_allocated_area = st.number_input( |
| "Product Allocated Area", |
| min_value=0.004, |
| max_value=0.298, |
| value= 0.004 |
| ) |
|
|
| store_establishment_year = st.number_input( |
| "Store Establishment Year", |
| min_value=1987, |
| max_value=2009, |
| value=1987, |
| help="Year the store was established" |
| ) |
|
|
| product_sugar_content = st.selectbox("Product Sugar Content", product_sugar_content_options) |
| product_type = st.selectbox("Product Type", product_type_options) |
| store_id = st.selectbox("Store Id", store_id_options) |
| store_size = st.selectbox("Store Size", store_size_options) |
| city_type = st.selectbox("Store Location City Type", city_type_options) |
| store_type = st.selectbox("Store Type", store_type_options) |
|
|
|
|
| |
| input_dict = { |
| "Product_Weight": product_weight, |
| "Product_Allocated_Area": product_allocated_area, |
| "Store_Establishment_Year": store_establishment_year, |
| "Product_Sugar_Content": product_sugar_content, |
| "Product_Type": product_type, |
| "Store_Id": store_id, |
| "Store_Size": store_size, |
| "Store_Location_City_Type": city_type, |
| "Store_Type": store_type |
| } |
|
|
| input_data = pd.DataFrame([input_dict]) |
|
|
| |
| input_data["Product_Store_Sales_Total"] = 0 |
|
|
| st.write("### Input Summary") |
| st.dataframe(input_data) |
|
|
|
|
|
|
| |
| if st.button("Predict Sales"): |
| prediction = model.predict(input_data) |
| st.write(f"The predicted Sales is ${prediction}") |
|
|
| st.markdown(""" |
| --- |
| *Built by the Sriranjan.* |
| """) |
|
|