Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
8ce4ad5
1
Parent(s):
db8ff4d
feat: updated website
Browse files
app.py
CHANGED
@@ -327,6 +327,32 @@ elif page == "Customer Analysis":
|
|
327 |
|
328 |
# Column 1: Radar chart for top manufacturers
|
329 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
# Radar chart logic remains the same
|
331 |
customer_df = df[df["CLIENTE"] == str(customer_code)]
|
332 |
all_manufacturers = customer_df.iloc[:, 1:].T
|
@@ -371,7 +397,7 @@ elif page == "Customer Analysis":
|
|
371 |
|
372 |
# Column 2: Alerts and additional analysis
|
373 |
with col2:
|
374 |
-
st.markdown(f"###
|
375 |
|
376 |
# Identify manufacturers that didn't meet predicted sales
|
377 |
underperforming_manufacturers = results[results['ventas_reales'] < results['ventas_predichas']].copy()
|
@@ -387,7 +413,7 @@ elif page == "Customer Analysis":
|
|
387 |
top_misses = underperforming_manufacturers.head(10)
|
388 |
|
389 |
# Display warnings for top 10 biggest misses
|
390 |
-
st.warning("
|
391 |
for index, row in top_misses.iterrows():
|
392 |
manufacturer_name = get_supplier_name(row['marca_id_encoded'])
|
393 |
predicted = row['ventas_predichas']
|
|
|
327 |
|
328 |
# Column 1: Radar chart for top manufacturers
|
329 |
with col1:
|
330 |
+
# Overperforming manufacturers alert
|
331 |
+
st.markdown(f"### Overperforming Manufacturers for {customer_code}")
|
332 |
+
|
333 |
+
# Identify manufacturers that exceeded predicted sales
|
334 |
+
overperforming_manufacturers = results[results['ventas_reales'] > results['ventas_predichas']].copy()
|
335 |
+
|
336 |
+
if not overperforming_manufacturers.empty:
|
337 |
+
# Calculate the extra amount (difference between actual and predicted sales)
|
338 |
+
overperforming_manufacturers['extra_amount'] = overperforming_manufacturers['ventas_reales'] - overperforming_manufacturers['ventas_predichas']
|
339 |
+
|
340 |
+
# Sort by the highest extra amount
|
341 |
+
overperforming_manufacturers = overperforming_manufacturers.sort_values(by='extra_amount', ascending=False)
|
342 |
+
|
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("Top 10 manufacturers that exceeded predicted sales:")
|
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 |
+
st.write(f"- {manufacturer_name}: Predicted = {predicted:.2f}€, Actual = {actual:.2f}€, Exceeded by = {extra:.2f}€")
|
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 |
|
398 |
# Column 2: Alerts and additional analysis
|
399 |
with col2:
|
400 |
+
st.markdown(f"### You might need to check this!")
|
401 |
|
402 |
# Identify manufacturers that didn't meet predicted sales
|
403 |
underperforming_manufacturers = results[results['ventas_reales'] < results['ventas_predichas']].copy()
|
|
|
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']
|