Handle sklearn version difference in ROCAUC scoring#698
Merged
Conversation
cristian-tamblay
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Older sklearn versions raise
ValueErrorinroc_auc_scorewhen a class is absent from a split during One-vs Rest (OvR) evaluation, while newer versions (e.g. 1.7.2) returnNaNwith a warning instead. This caused training jobs to crash on machines with older sklearn while working fine on machines with newer sklearn. The fix wraps theroc_auc_scorecall in atry/except ValueErrorso both behaviors normalize tofloat("nan"), whichbase_model.calculate_metricsalready filters out viamath.isfinite.Type of Change
Changes (by file)
DashAI/back/metrics/classification/roc_auc.py: wraproc_auc_scorecall intry/except ValueErrorto returnfloat("nan")instead of propagating the exception when a class is absent from a split in OvR mode.Testing (optional)
Train a classification model with an imbalanced dataset (no stratified split) so at least one class is absent from validation/test. Confirm training completes and ROCAUC is omitted from those splits instead of crashing the job.
Notes (optional)
This bug only manifests when: (1) the task is multiclass, (2) the dataset is split without stratification, and (3) at least one class has no samples in the validation or test split. The
calculate_metricscall happens inside the training loop (per epoch/step), so the crash occurs early during training rather than at the end.