GMARTINEZMILLA commited on
Commit
2148f2d
·
1 Parent(s): eb433cf

feat: updated website

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -263,7 +263,7 @@ elif page == "Customer Analysis":
263
  with st.spinner("We are identifying the customer's cluster..."):
264
  # Find Customer's Cluster
265
  customer_match = customer_clusters[customer_clusters['cliente_id'] == customer_code]
266
- time.sleep(2)
267
 
268
 
269
  if not customer_match.empty:
@@ -273,7 +273,7 @@ elif page == "Customer Analysis":
273
  # Load the Corresponding Model
274
  model_path = f'models/modelo_cluster_{cluster}.txt'
275
  gbm = lgb.Booster(model_file=model_path)
276
- time.sleep(2)
277
 
278
  with st.spinner("Getting the data ready..."):
279
  # Load predict data for that cluster
@@ -321,9 +321,9 @@ elif page == "Customer Analysis":
321
  how='left')
322
  results.rename(columns={'precio_total': 'ventas_reales'}, inplace=True)
323
  results['ventas_reales'].fillna(0, inplace=True)
324
- st.write("### Final Results DataFrame:")
325
- st.write(results.head())
326
- st.write(f"Shape: {results.shape}")
327
 
328
  # Calculate metrics only for non-null actual sales
329
  valid_results = results.dropna(subset=['ventas_reales'])
@@ -333,23 +333,23 @@ elif page == "Customer Analysis":
333
  mape = np.mean(np.abs((non_zero_actuals['ventas_reales'] - non_zero_actuals['ventas_predichas']) / non_zero_actuals['ventas_reales'])) * 100
334
  rmse = np.sqrt(mean_squared_error(valid_results['ventas_reales'], valid_results['ventas_predichas']))
335
 
336
- st.write(f"Actual total sales for Customer {customer_code}: {valid_results['ventas_reales'].sum():.2f}")
337
- st.write(f"MAE: {mae:.2f}€")
338
- st.write(f"MAPE: {mape:.2f}%")
339
- st.write(f"RMSE: {rmse:.2f}")
340
-
341
- # Analysis of results
342
- threshold_good = 100 # You may want to adjust this threshold
343
- if mae < threshold_good:
344
- st.success(f"Customer {customer_code} is performing well based on the predictions.")
345
- else:
346
- st.warning(f"Customer {customer_code} is not performing well based on the predictions.")
347
- else:
348
- st.warning(f"No actual sales data found for customer {customer_code} in df_agg_2024.")
349
-
350
- st.write("### Debug Information for Radar Chart:")
351
- st.write(f"Shape of customer_data: {customer_data.shape}")
352
- st.write(f"Shape of euros_proveedor: {euros_proveedor.shape}")
353
 
354
  # Get percentage of units sold for each manufacturer
355
  customer_df = df[df["CLIENTE"] == str(customer_code)] # Get the customer data
 
263
  with st.spinner("We are identifying the customer's cluster..."):
264
  # Find Customer's Cluster
265
  customer_match = customer_clusters[customer_clusters['cliente_id'] == customer_code]
266
+ time.sleep(1)
267
 
268
 
269
  if not customer_match.empty:
 
273
  # Load the Corresponding Model
274
  model_path = f'models/modelo_cluster_{cluster}.txt'
275
  gbm = lgb.Booster(model_file=model_path)
276
+ time.sleep(1)
277
 
278
  with st.spinner("Getting the data ready..."):
279
  # Load predict data for that cluster
 
321
  how='left')
322
  results.rename(columns={'precio_total': 'ventas_reales'}, inplace=True)
323
  results['ventas_reales'].fillna(0, inplace=True)
324
+ # st.write("### Final Results DataFrame:")
325
+ # st.write(results.head())
326
+ # st.write(f"Shape: {results.shape}")
327
 
328
  # Calculate metrics only for non-null actual sales
329
  valid_results = results.dropna(subset=['ventas_reales'])
 
333
  mape = np.mean(np.abs((non_zero_actuals['ventas_reales'] - non_zero_actuals['ventas_predichas']) / non_zero_actuals['ventas_reales'])) * 100
334
  rmse = np.sqrt(mean_squared_error(valid_results['ventas_reales'], valid_results['ventas_predichas']))
335
 
336
+ # st.write(f"Actual total sales for Customer {customer_code}: {valid_results['ventas_reales'].sum():.2f}")
337
+ # st.write(f"MAE: {mae:.2f}€")
338
+ # st.write(f"MAPE: {mape:.2f}%")
339
+ # st.write(f"RMSE: {rmse:.2f}")
340
+
341
+ # # Analysis of results
342
+ # threshold_good = 100 # You may want to adjust this threshold
343
+ # if mae < threshold_good:
344
+ # st.success(f"Customer {customer_code} is performing well based on the predictions.")
345
+ # else:
346
+ # st.warning(f"Customer {customer_code} is not performing well based on the predictions.")
347
+ # else:
348
+ # st.warning(f"No actual sales data found for customer {customer_code} in df_agg_2024.")
349
+
350
+ # st.write("### Debug Information for Radar Chart:")
351
+ # st.write(f"Shape of customer_data: {customer_data.shape}")
352
+ # st.write(f"Shape of euros_proveedor: {euros_proveedor.shape}")
353
 
354
  # Get percentage of units sold for each manufacturer
355
  customer_df = df[df["CLIENTE"] == str(customer_code)] # Get the customer data