fix(metrics): ignore NaN target/prediction pairs in validation metrics (SIENTIAPDE-2215)
This commit is contained in:
@@ -405,6 +405,23 @@ class DataManagerRepository(SientiaMonitoring):
|
||||
y_true_val = y_true_val.loc[common_index]
|
||||
y_pred_val = y_pred_val.loc[common_index]
|
||||
|
||||
# NaN target, or NaN prediction for rows with NaN features, carries no error signal
|
||||
# (SIENTIAPDE-2215).
|
||||
valid = y_true_val.notna() & y_pred_val.notna()
|
||||
if not valid.any():
|
||||
raise ValueError(
|
||||
'No validation rows with both target and prediction: all '
|
||||
f'{len(valid)} overlapping rows have NaN'
|
||||
)
|
||||
if not valid.all():
|
||||
self.info(
|
||||
f'Ignoring {int((~valid).sum())} validation row(s) with NaN target or prediction '
|
||||
'in the regression metrics',
|
||||
metadata,
|
||||
)
|
||||
y_true_val = y_true_val[valid]
|
||||
y_pred_val = y_pred_val[valid]
|
||||
|
||||
# Metrics helpers already round to 2 decimals.
|
||||
tmr.mse_val = mse(y_true_val, y_pred_val)
|
||||
tmr.mae_val = mae(y_true_val, y_pred_val)
|
||||
|
||||
Reference in New Issue
Block a user