File size: 7,696 Bytes
62205a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
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("""

<style>



html, body, [class*="css"] {

    font-family: 'Segoe UI', sans-serif;

}



.main {

    background: #f5f7fb;

}



.block-container {

    max-width: 1200px;

    padding-top: 2rem;

    padding-bottom: 2rem;

    padding-left: 1rem;

    padding-right: 1rem;

}



.hero {

    background: linear-gradient(135deg,#111827,#2563eb);

    padding: 2.5rem;

    border-radius: 28px;

    color: white;

    margin-bottom: 2rem;

}



.hero h1 {

    font-size: 48px;

    font-weight: 800;

    margin-bottom: 0.5rem;

}



.hero p {

    font-size: 18px;

    opacity: 0.9;

}



.card {

    background: white;

    border-radius: 24px;

    padding: 1.5rem;

    box-shadow: 0 6px 18px rgba(0,0,0,0.08);

    margin-bottom: 1rem;

}



.result-box {

    background: linear-gradient(135deg,#16a34a,#22c55e);

    padding: 2rem;

    border-radius: 24px;

    text-align: center;

    color: white;

    margin-top: 1rem;

}



.metric-card {

    background: white;

    padding: 1rem;

    border-radius: 18px;

    box-shadow: 0 4px 14px rgba(0,0,0,0.06);

    text-align: center;

}



.stButton > button {

    width: 100%;

    height: 58px;

    border-radius: 16px;

    border: none;

    background: linear-gradient(135deg,#2563eb,#1d4ed8);

    color: white;

    font-size: 20px;

    font-weight: 700;

}



.stButton > button:hover {

    background: linear-gradient(135deg,#1d4ed8,#1e40af);

}



div[data-baseweb="select"] {

    border-radius: 14px !important;

}



div[data-baseweb="slider"] {

    padding-top: 1rem;

    padding-bottom: 1rem;

}



@media (max-width: 768px){



    .hero {

        padding: 1.5rem;

    }



    .hero h1 {

        font-size: 30px;

    }



    .hero p {

        font-size: 15px;

    }



    .stButton > button {

        height: 54px;

        font-size: 18px;

    }



    .block-container {

        padding-left: 0.7rem;

        padding-right: 0.7rem;

    }

}



</style>

""", 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("""

<div class="hero">

    <h1>📈 AI Rossmann Sales Predictor</h1>

    <p>

        Predict daily Rossmann store sales using AI-powered analytics.

        Modern responsive interface optimized for desktop and mobile devices.

    </p>

</div>

""", unsafe_allow_html=True)

# =========================================================
# INFO METRICS
# =========================================================
m1, m2, m3 = st.columns(3)

with m1:
    st.markdown("""

    <div class="metric-card">

        <h3>⚡ Fast Prediction</h3>

        <p>Instant AI analysis</p>

    </div>

    """, unsafe_allow_html=True)

with m2:
    st.markdown("""

    <div class="metric-card">

        <h3>📱 Mobile Friendly</h3>

        <p>Responsive modern design</p>

    </div>

    """, unsafe_allow_html=True)

with m3:
    st.markdown("""

    <div class="metric-card">

        <h3>🧠 Deep Learning</h3>

        <p>Neural network prediction</p>

    </div>

    """, unsafe_allow_html=True)

st.write("")

# =========================================================
# MAIN FORM
# =========================================================
st.markdown('<div class="card">', 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('</div>', 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"""

    <div class="result-box">

        <h2>Predicted Daily Sales</h2>

        <h1 style="font-size:72px;">€{predicted_sales:,}</h1>

        <p>AI-powered Rossmann sales estimation completed successfully</p>

    </div>

    """, 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.")