SuperKart_Streamlit_Only / streamlit_app.py
dhani10's picture
Update streamlit_app.py
58e92dd verified
# import requests
# import streamlit as st
# import numpy as np
# st.title("SuperKart Sales Forecast")
# inputs = [st.number_input(f"Enter {name}", value=0.0) for name in [
# "Product_Weight", "Product_Allocated_Area", "Product_MRP", "Store_Establishment_Year"
# ]]
# if st.button("Predict Sales"):
# try:
# response = requests.post("http://localhost:5000/predict", json={"features": inputs})
# st.success(f"Predicted Sales: {response.json()['prediction']}")
# except Exception as e:
# st.error(f"Error: {e}")
import os
os.environ["XDG_CONFIG_HOME"] = "/tmp"
import streamlit as st
import joblib
import numpy as np
st.set_page_config(page_title="SuperKart Forecast", layout="centered")
st.title("πŸ›’ SuperKart Sales Forecast")
# Load the trained model
model = joblib.load("random_forest_best_model.pkl")
# Input fields
st.subheader("Enter Product & Store Details")
feature_names = ['Product_Weight', 'Product_Allocated_Area', 'Product_MRP', 'Store_Establishment_Year']
inputs = [st.number_input(f"{feature}", value=0.0, step=0.01) for feature in feature_names]
# Prediction
if st.button("πŸ“ˆ Predict Sales"):
features = np.array(inputs).reshape(1, -1)
prediction = model.predict(features)
st.success(f"πŸ“Š Predicted Sales Revenue: β‚Ή{prediction[0]:,.2f}")