GMARTINEZMILLA commited on
Commit
c613d19
1 Parent(s): 8ca9f60

feat: Updated mape calculation

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -459,10 +459,14 @@ elif page == "🕵️ Análisis de Cliente":
459
  actual = datos_2024['ventas_reales']
460
  predicted = datos_2024['ventas_predichas']
461
 
 
 
 
 
462
  mae = mean_absolute_error(actual, predicted)
463
  mse = mean_squared_error(actual, predicted)
464
  rmse = np.sqrt(mse)
465
- mape = np.mean(np.abs((actual - predicted) / actual)) * 100
466
  smape = np.mean(2 * np.abs(actual - predicted) / (np.abs(actual) + np.abs(predicted))) * 100
467
 
468
  # Display metrics
 
459
  actual = datos_2024['ventas_reales']
460
  predicted = datos_2024['ventas_predichas']
461
 
462
+ def calculate_mape(y_true, y_pred):
463
+ mask = y_true != 0
464
+ return np.mean(np.abs((y_true[mask] - y_pred[mask]) / y_true[mask])) * 100
465
+
466
  mae = mean_absolute_error(actual, predicted)
467
  mse = mean_squared_error(actual, predicted)
468
  rmse = np.sqrt(mse)
469
+ mape = calculate_mape(actual, predicted)
470
  smape = np.mean(2 * np.abs(actual - predicted) / (np.abs(actual) + np.abs(predicted))) * 100
471
 
472
  # Display metrics