Spaces:
Sleeping
Sleeping
| # 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}") | |