Harden prediction load and multiclass CV against invalid/empty input#391
Merged
gbeane merged 1 commit intoJun 3, 2026
Merged
Conversation
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.
Addresses two robustness review comments from the
feature/multiclass→mainPR.1.
prediction_manager— invalid/corrupted prediction recordsio.load()raisesValueErrorwhen a saved record has an invalid schema (e.g.class_namespresent but probabilities are 2-D instead of(n_id, n_frames, n_classes))._load_prediction_recordonly caughtKeyError/FileNotFoundError, soload_multiclass_predictions()would propagate the error instead of falling back to empty outputs.io.loadis now wrapped so aValueError(corrupt/invalid record) returns empty outputs, consistent with the missing-file behavior.test_load_multiclass_predictions_invalid_shape_returns_empty, which previously passed for the wrong reason: it wrote the group as__multiclass__while the loader looks it up viato_safe_name(...)=multiclass, so it hit aKeyErrorand never exercised the invalid-shape path. It now writes the correct safe group name and genuinely exercises theValueErrorfallback.2.
cross_validation— emptylabels_by_behaviorIn multi-class mode
_prepare_cv_labelscalledmerge_labels(...)unconditionally;merge_labelsraises on an empty dict (no labeled frames yet), so CV crashed instead of being skipped like the binary path._prepare_cv_labelsnow short-circuits on emptylabels_by_behavior, returning an empty label array so the caller finds no valid splits and skips CV gracefully.Tests
test_multiclass_cv_skips_when_no_labels(CV skipped, no raise).tests/classifier+tests/project(298) pass; ruff clean.