File size: 1,117 Bytes
1cb64e9 0d12aa2 1cb64e9 0d12aa2 1cb64e9 0d12aa2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import streamlit as st
import numpy as np
import pickle
import pandas as pd
# Load the trained model
def load_model():
with open("walmart_sales_model.pkl", "rb") as f:
model = pickle.load(f)
return model
# Load the model
model = load_model()
# Streamlit UI
def main():
st.title("🛒 Walmart Sales Prediction")
st.write("Enter the input features below to predict the weekly sales.")
# User inputs
store = st.number_input("Enter Store ID", min_value=1, max_value=50, value=1)
temp = st.number_input("Enter Temperature (Celsius)", value=20.0)
fuel_price = st.number_input("Enter Fuel Price", value=3.5)
cpi = st.number_input("Enter CPI", value=200.0)
unemployment = st.number_input("Enter Unemployment Rate", value=5.0)
holiday_flag = st.selectbox("Is it a Holiday?", [0, 1])
if st.button("Predict Sales"):
features = np.array([[store, temp, fuel_price, cpi, unemployment, holiday_flag]])
prediction = model.predict(features)
st.success(f"Predicted Weekly Sales: ${prediction[0]:,.2f}")
if __name__ == "__main__":
main()
|