Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import pandas as pd | |
| from sklearn.linear_model import LinearRegression | |
| # Streamlit page config | |
| st.set_page_config(page_title="BigMart Sales Predictor", page_icon="🛒", layout="centered") | |
| st.title("🛒 BigMart Sales Prediction") | |
| st.markdown("Enter item details below to predict sales:") | |
| # Input fields | |
| project_name = st.text_input("📦 Project Name") | |
| item_weight = st.number_input("⚖️ Item Weight (kg)", min_value=0.0, step=0.1) | |
| item_visibility = st.slider("👀 Item Visibility", 0.0, 1.0, 0.1) | |
| item_mrp = st.number_input("💰 Item MRP (Max Retail Price)", min_value=0.0, step=1.0) | |
| # Predict button | |
| if st.button("Predict Sales"): | |
| if not project_name: | |
| st.warning("Please enter a project name.") | |
| else: | |
| # Dummy ML Model: Replace with your actual trained model | |
| X_train = np.array([ | |
| [9.3, 0.016, 249.8], | |
| [5.92, 0.019, 48.27], | |
| [17.5, 0.016, 141.62], | |
| [19.2, 0.0075, 182.095], | |
| ]) | |
| y_train = np.array([3735.14, 443.42, 2233.6, 3612.47]) # example sales | |
| model = LinearRegression() | |
| model.fit(X_train, y_train) | |
| # Prepare input | |
| user_input = np.array([[item_weight, item_visibility, item_mrp]]) | |
| prediction = model.predict(user_input)[0] | |
| st.success(f"📈 Predicted Sales for '{project_name}': ₹{prediction:,.2f}") | |
| # Sidebar info | |
| st.sidebar.title("📌 About") | |
| st.sidebar.markdown( | |
| """ | |
| This app uses a simple ML model to estimate sales based on: | |
| - Item weight | |
| - Item visibility | |
| - Item MRP | |
| Replace with a trained BigMart dataset model for production use. | |
| """ | |
| ) | |