import streamlit as st from tensorflow.keras.models import load_model import numpy as np # ========================================================= # PAGE CONFIG # ========================================================= st.set_page_config( page_title="AI Sales Predictor", page_icon="📈", layout="wide", initial_sidebar_state="collapsed" ) # ========================================================= # CUSTOM CSS # ========================================================= st.markdown(""" """, unsafe_allow_html=True) # ========================================================= # LOAD MODEL # ========================================================= @st.cache_resource def load_ai_model(): return load_model("rossmann.h5") model = load_ai_model() # ========================================================= # HERO SECTION # ========================================================= st.markdown("""

📈 AI Rossmann Sales Predictor

Predict daily Rossmann store sales using AI-powered analytics. Modern responsive interface optimized for desktop and mobile devices.

""", unsafe_allow_html=True) # ========================================================= # INFO METRICS # ========================================================= m1, m2, m3 = st.columns(3) with m1: st.markdown("""

⚡ Fast Prediction

Instant AI analysis

""", unsafe_allow_html=True) with m2: st.markdown("""

📱 Mobile Friendly

Responsive modern design

""", unsafe_allow_html=True) with m3: st.markdown("""

🧠 Deep Learning

Neural network prediction

""", unsafe_allow_html=True) st.write("") # ========================================================= # MAIN FORM # ========================================================= st.markdown('
', unsafe_allow_html=True) st.subheader("Store Information") col1, col2 = st.columns(2) # ========================================================= # LEFT COLUMN # ========================================================= with col1: customers = st.slider( "👥 Number of Customers", min_value=0, max_value=10000, value=1200, step=50 ) day_name = st.selectbox( "📅 Day of the Week", [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] ) # ========================================================= # RIGHT COLUMN # ========================================================= with col2: store_open = st.selectbox( "🏪 Store Status", [ "Open", "Closed" ] ) promo = st.selectbox( "🎯 Promotion Active", [ "Yes", "No" ] ) st.write("") predict_btn = st.button("🚀 Predict Sales") st.markdown('
', unsafe_allow_html=True) # ========================================================= # ENCODING # ========================================================= open_value = 1 if store_open == "Open" else 0 promo_value = 1 if promo == "Yes" else 0 day_mapping = { "Monday": 1, "Tuesday": 2, "Wednesday": 3, "Thursday": 4, "Friday": 5, "Saturday": 6, "Sunday": 7 } day_value = day_mapping[day_name] # ========================================================= # PREDICTION # ========================================================= if predict_btn: input_data = np.array([ customers, open_value, day_value, promo_value ]) if len(input_data.shape) == 1: input_data = np.expand_dims(input_data, axis=0) with st.spinner("AI is predicting sales..."): prediction = model.predict(input_data, verbose=0) predicted_sales = int(prediction[0][0]) # ===================================================== # RESULT CARD # ===================================================== st.markdown(f"""

Predicted Daily Sales

€{predicted_sales:,}

AI-powered Rossmann sales estimation completed successfully

""", unsafe_allow_html=True) st.write("") # ===================================================== # ANALYTICS CARDS # ===================================================== a1, a2, a3 = st.columns(3) with a1: st.metric( "Customers", f"{customers:,}" ) with a2: st.metric( "Promotion", "Active" if promo_value == 1 else "Inactive" ) with a3: st.metric( "Store Status", "Open" if open_value == 1 else "Closed" ) # ===================================================== # SALES INSIGHT # ===================================================== st.write("") if predicted_sales > 15000: st.success("🔥 High sales potential detected for this store day.") elif predicted_sales > 7000: st.info("📈 Average to strong daily sales expected.") else: st.warning("⚠️ Lower sales prediction detected.")