Migrate _classification and _ranking metrics to new input validation infrastructure - #8012
Merged
Merged
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughRefactors cuML metrics input validation to use scikit-learn utilities ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
csadorf
force-pushed
the
metrics-new-validation
branch
from
April 24, 2026 15:49
293b8b7 to
e002c66
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@python/cuml/cuml/metrics/_classification.py`:
- Around line 37-42: The broad except (ValueError, TypeError) is converting
validation errors into a cudf.Series fallback; change the logic so we only fall
back to cudf for unsupported label dtypes (e.g., object/str/categorical) and
re-raise for dimensionality/shape/type validation errors: before creating
cudf.Series(x, ...), inspect x's dtype (e.g., via numpy.asarray(x).dtype or
pandas.api.types.is_object_dtype / is_categorical_dtype) and if it indicates an
unsupported label dtype then execute the cudf fallback (assign to out),
otherwise let the original exception propagate (re-raise) so functions like
whatever calls this code continue to enforce shape/dimensionality validation.
Ensure you reference x and out in the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ef3dae8c-8622-432a-b744-2860f7de983a
📒 Files selected for processing (4)
python/cuml/cuml/metrics/_classification.pypython/cuml/cuml/metrics/_ranking.pypython/cuml/cuml_accel_tests/upstream/scikit-learn/xfail-list.yamlpython/cuml/tests/test_metrics.py
💤 Files with no reviewable changes (1)
- python/cuml/cuml_accel_tests/upstream/scikit-learn/xfail-list.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
- python/cuml/tests/test_metrics.py
- python/cuml/cuml/metrics/_ranking.py
Member
|
/merge |
This was referenced May 1, 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.
Migrate _classification and _ranking metrics to new input validation infrastructure
Part of #7998
Part of #7428