Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 07346522-64e9-4d8c-b1fa-70c33b60a349
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the PCA rank-validation change.
No open issues 🎉
What changed in this PR
This PR prevents PCA whitening from accepting a rank larger than the input dimension, avoiding out-of-bounds reads during scoring in ML.NET.
Changes:
- Validates PCA rank before training and when binding a transformer, including loaded models.
- Preserves ZCA behavior, which ignores rank.
- Adds regression tests for oversized ranks, valid boundary values, and invalid ranks in loaded models.
| File | Description |
|---|---|
test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs |
Adds rank-validation and model-loading regression tests. |
src/Microsoft.ML.Mkl.Components/VectorWhitening.cs |
Adds a shared PCA rank check to training and transformer binding. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7962 +/- ##
=======================================
Coverage 70.89% 70.89%
=======================================
Files 1421 1421
Lines 280133 280167 +34
Branches 27601 27602 +1
=======================================
+ Hits 198591 198638 +47
+ Misses 73407 73391 -16
- Partials 8135 8138 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Nov 26, 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.
PCA whitening accepts a rank larger than the input dimension, which can read past the learned matrix during scoring. Validate the rank before training and when binding a transformer, including one loaded from an older model. ZCA continues to ignore the rank.
Note
This description was generated by Copilot.