Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
145c4e5
1
Parent(s):
5cb1f26
feat: updated website
Browse files
app.py
CHANGED
@@ -328,7 +328,8 @@ elif page == "Customer Analysis":
|
|
328 |
# Column 1: Radar chart for top manufacturers
|
329 |
with col1:
|
330 |
# Overperforming manufacturers alert
|
331 |
-
st.
|
|
|
332 |
|
333 |
# Identify manufacturers that exceeded predicted sales
|
334 |
overperforming_manufacturers = results[results['ventas_reales'] > results['ventas_predichas']].copy()
|
@@ -343,16 +344,23 @@ elif page == "Customer Analysis":
|
|
343 |
# Limit to top 10 overperforming manufacturers
|
344 |
top_overperformers = overperforming_manufacturers.head(10)
|
345 |
|
346 |
-
# Display alerts for top 10 biggest overperformers
|
347 |
-
st.success("Your customer did exceed predicted sales from the following brands:")
|
348 |
for index, row in top_overperformers.iterrows():
|
349 |
manufacturer_name = get_supplier_name(row['marca_id_encoded'])
|
350 |
predicted = row['ventas_predichas']
|
351 |
actual = row['ventas_reales']
|
352 |
extra = row['extra_amount']
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
else:
|
355 |
st.info("No manufacturers exceeded predicted sales.")
|
|
|
|
|
356 |
# Radar chart logic remains the same
|
357 |
customer_df = df[df["CLIENTE"] == str(customer_code)]
|
358 |
all_manufacturers = customer_df.iloc[:, 1:].T
|
@@ -397,13 +405,14 @@ elif page == "Customer Analysis":
|
|
397 |
|
398 |
# Column 2: Alerts and additional analysis
|
399 |
with col2:
|
400 |
-
st.
|
401 |
-
|
|
|
402 |
# Identify manufacturers that didn't meet predicted sales
|
403 |
underperforming_manufacturers = results[results['ventas_reales'] < results['ventas_predichas']].copy()
|
404 |
-
|
405 |
if not underperforming_manufacturers.empty:
|
406 |
-
# Calculate the missed amount
|
407 |
underperforming_manufacturers['missed_amount'] = underperforming_manufacturers['ventas_predichas'] - underperforming_manufacturers['ventas_reales']
|
408 |
|
409 |
# Sort by the highest missed amount
|
@@ -412,14 +421,19 @@ elif page == "Customer Analysis":
|
|
412 |
# Limit to top 10 missed amounts
|
413 |
top_misses = underperforming_manufacturers.head(10)
|
414 |
|
415 |
-
# Display warnings for top 10 biggest misses
|
416 |
-
st.warning("Your customer was expected to buy more products from the following brands:")
|
417 |
for index, row in top_misses.iterrows():
|
418 |
manufacturer_name = get_supplier_name(row['marca_id_encoded'])
|
419 |
predicted = row['ventas_predichas']
|
420 |
actual = row['ventas_reales']
|
421 |
missed = row['missed_amount']
|
422 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
else:
|
424 |
st.success("All manufacturers have met or exceeded predicted sales.")
|
425 |
|
|
|
328 |
# Column 1: Radar chart for top manufacturers
|
329 |
with col1:
|
330 |
# Overperforming manufacturers alert
|
331 |
+
st.subheader("This looks great!")
|
332 |
+
st.info("Your customer did exceed predicted sales from the following brands:")
|
333 |
|
334 |
# Identify manufacturers that exceeded predicted sales
|
335 |
overperforming_manufacturers = results[results['ventas_reales'] > results['ventas_predichas']].copy()
|
|
|
344 |
# Limit to top 10 overperforming manufacturers
|
345 |
top_overperformers = overperforming_manufacturers.head(10)
|
346 |
|
|
|
|
|
347 |
for index, row in top_overperformers.iterrows():
|
348 |
manufacturer_name = get_supplier_name(row['marca_id_encoded'])
|
349 |
predicted = row['ventas_predichas']
|
350 |
actual = row['ventas_reales']
|
351 |
extra = row['extra_amount']
|
352 |
+
|
353 |
+
# Use Streamlit's st.metric for better styling
|
354 |
+
st.metric(
|
355 |
+
label=f"{manufacturer_name}",
|
356 |
+
value=f"{actual:.2f}€",
|
357 |
+
delta=f"Exceeded by {extra:.2f}€",
|
358 |
+
delta_color="normal"
|
359 |
+
)
|
360 |
else:
|
361 |
st.info("No manufacturers exceeded predicted sales.")
|
362 |
+
|
363 |
+
|
364 |
# Radar chart logic remains the same
|
365 |
customer_df = df[df["CLIENTE"] == str(customer_code)]
|
366 |
all_manufacturers = customer_df.iloc[:, 1:].T
|
|
|
405 |
|
406 |
# Column 2: Alerts and additional analysis
|
407 |
with col2:
|
408 |
+
st.subheader("You might need to check this!")
|
409 |
+
st.warning("Your customer was expected to buy more products from the following brands:")
|
410 |
+
|
411 |
# Identify manufacturers that didn't meet predicted sales
|
412 |
underperforming_manufacturers = results[results['ventas_reales'] < results['ventas_predichas']].copy()
|
413 |
+
|
414 |
if not underperforming_manufacturers.empty:
|
415 |
+
# Calculate the missed amount
|
416 |
underperforming_manufacturers['missed_amount'] = underperforming_manufacturers['ventas_predichas'] - underperforming_manufacturers['ventas_reales']
|
417 |
|
418 |
# Sort by the highest missed amount
|
|
|
421 |
# Limit to top 10 missed amounts
|
422 |
top_misses = underperforming_manufacturers.head(10)
|
423 |
|
|
|
|
|
424 |
for index, row in top_misses.iterrows():
|
425 |
manufacturer_name = get_supplier_name(row['marca_id_encoded'])
|
426 |
predicted = row['ventas_predichas']
|
427 |
actual = row['ventas_reales']
|
428 |
missed = row['missed_amount']
|
429 |
+
|
430 |
+
# Use Streamlit's st.metric for better styling
|
431 |
+
st.metric(
|
432 |
+
label=f"{manufacturer_name}",
|
433 |
+
value=f"{actual:.2f}€",
|
434 |
+
delta=f"Missed by {missed:.2f}€",
|
435 |
+
delta_color="inverse"
|
436 |
+
)
|
437 |
else:
|
438 |
st.success("All manufacturers have met or exceeded predicted sales.")
|
439 |
|