Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| import numpy as np | |
| # Load the trained model | |
| def load_model(): | |
| return joblib.load("SuperKart_Model_V1_0.joblib") | |
| model = load_model() | |
| # Streamlit UI for Price Prediction | |
| st.title("SuperKart Revenue Prediction App") | |
| st.write("This tool predicts the sales revenue listing based on the given details.") | |
| st.subheader("Enter the listing details:") | |
| # Collect user input | |
| Product_Type = st.selectbox("Product_Type", ["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"]) | |
| Product_Weight = st.number_input("Product_Weight", min_value=0.0, value=12.66) | |
| Product_MRP = st.number_input("Product_MRP",min_value=0.0, value=100.0) | |
| Product_Allocated_Area = st.number_input("Product_Allocated_Area", min_value=0.0, value=100.0) | |
| Product_Sugar_Content = st.selectbox("Product_Sugar_Content", ["Low Sugar", "No Sugar", "Regular", "reg"]) | |
| Store_Type = st.selectbox("Store_Type", ["Supermarket Type2 ", "Supermarket Type1","Departmental Store","Food Mart"]) | |
| Store_Location_City_Type = st.selectbox("Store_Location_City_Type", ["Tier 2", "Tier 1","Tier 3"]) | |
| Store_Id = st.selectbox("Store_Id",["OUT004","OUT003","OUT002","OUT001"]) | |
| Store_Establishment_Year = st.number_input( | |
| "Store_Establishment_Year", | |
| min_value=1900, | |
| max_value=2025, | |
| step=1, | |
| value=2000, | |
| format='%d' | |
| ) | |
| # Convert user input into a DataFrame | |
| input_data = pd.DataFrame([{ | |
| 'Product_Type': Product_Type, | |
| 'Product_Weight': Product_Weight, | |
| 'Product_MRP': Product_MRP, | |
| 'Product_Allocated_Area': Product_Allocated_Area, | |
| 'Product_Sugar_Content': Product_Sugar_Content, | |
| 'Store_Type': Store_Type, | |
| 'Store_Location_City_Type': Store_Location_City_Type, | |
| 'Store_Id': Store_Id, | |
| 'Store_Establishment_Year': Store_Establishment_Year, | |
| }]) | |
| # Predict button | |
| if st.button("Predict"): | |
| prediction = model.predict(input_data) | |
| #st.write(f"The predicted revnue is ${np.exp(prediction)[0]:.2f}.") | |
| st.write(f"The predicted revenue is ${prediction[0]:.2f}.") | |