|
import streamlit as st |
|
import numpy as np |
|
from sklearn.linear_model import LinearRegression |
|
|
|
|
|
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:") |
|
|
|
|
|
project_name = st.text_input("📦 Project Name") |
|
item_weight = st.number_input("⚖️ Item Weight (in kg)", min_value=0.0, step=0.1) |
|
item_visibility = st.slider("👀 Item Visibility", 0.0, 1.0, 0.05) |
|
item_mrp = st.number_input("💰 Item MRP", min_value=0.0, step=1.0) |
|
|
|
|
|
if st.button("Predict Sales"): |
|
if not project_name: |
|
st.warning("Please enter a project name.") |
|
else: |
|
|
|
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]) |
|
|
|
|
|
model = LinearRegression() |
|
model.fit(X_train, y_train) |
|
|
|
|
|
user_input = np.array([[item_weight, item_visibility, item_mrp]]) |
|
predicted_sales = model.predict(user_input)[0] |
|
|
|
st.success(f"📈 Predicted Sales for '{project_name}': ₹{predicted_sales:,.2f}") |
|
|
|
|
|
st.sidebar.title("📌 About") |
|
st.sidebar.markdown( |
|
""" |
|
This app predicts sales based on item weight, visibility, and MRP using a demo ML model. |
|
|
|
🔧 Replace with a trained model on BigMart dataset for real-world use! |
|
""" |
|
) |
|
|