sree4411's picture
Update app.py
0d12aa2 verified
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()