-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
ENH Array API support for PCA #26315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thomasjpfan
merged 79 commits into
scikit-learn:main
from
mtsokol:feature/array_api_compat_pca
Jul 13, 2023
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
dd4c9fc
ENH Adds PyTorch support for PCA
mtsokol ceb10e3
ENH Support get_precision and get_covariance
mtsokol 0b8592c
Merge branch 'main' into feature/array_api_compat_pca
mtsokol 2ae83c0
ENH apply review comments
mtsokol 1b4a7cd
Fix multi-fancy indexing via using xp.take on flattened arrays in svd…
ogrisel cf86c45
Unit test for svd_flip
ogrisel c84e4ef
Fix stide related logic in call to xp.take with 1d args
ogrisel 3194b7e
Delete dead code
ogrisel f1546c4
Run PCA array API tests manually
ogrisel fd8a217
Do note check concrete values in Array API common test by default
ogrisel 51c9596
Move namespace+parameter generation to _array_api
betatim 8f67f46
Rename function
betatim e1b7230
Test .score and .score_samples
ogrisel 9c90da9
Progress on fixing .score
ogrisel 697618e
Make accuracy_score and score return float explicitly
ogrisel 5cb75eb
Merge branch 'main' into feature/array_api_compat_pca
ogrisel a7aba27
Fix docstests and test_check_array_api_input
ogrisel 7b37bca
Fix one more doctest fix
ogrisel b457925
Cosmit
ogrisel 76315eb
Fix one more doctest fix
ogrisel 8291a02
Move and update changelog entry
ogrisel 25e80f4
Update the Array API doc page to mention PCA
ogrisel 73787fe
WIP array api for randomized_svd
ogrisel 3fd48c1
Merge main
ogrisel f97e1d7
pytest parametrization to run custom Array API checks in test_pca
ogrisel 9afc7dc
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 266e1a9
Pass estimator to check yielder
ogrisel e1272e2
Update sklearn/decomposition/_base.py
ogrisel 0916c85
Fix check_array_api_input and update PCA accordingly
ogrisel 41fbc6a
Compare namespace names
ogrisel b50542e
Keep on using scipy.linalg.svd in PCA by default
ogrisel 51b348a
Merge branch 'main' into feature/array_api_compat_pca
ogrisel f3e6ebf
Merge branch 'main' into feature/array_api_compat_pca
ogrisel e044dc8
cosmetics
ogrisel e1c1474
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 6586822
Test errors when calling PCA with unsupported parameter values
ogrisel e232837
Protect array_api test against missing soft dependency
ogrisel 764e246
More consistent use of scipy.linalg when array api is disabled
ogrisel a21bac4
Merge branch 'main' into feature/array_api_compat_pca
ogrisel efe75a0
Improve coverage and simplify code
ogrisel 396752b
Comment about lazy evaluation
ogrisel 3396e46
Simplify power iteration by using @ instead
ogrisel dfe0b55
Update sklearn/utils/_array_api.py
ogrisel 713f88e
Clean-up left over
ogrisel 3bf6e50
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 6920561
Fix randomized_range_finder docstring to reflect the latest version o…
ogrisel 6ff1ab1
Better not use np.newaxis in Array API code
ogrisel 60e307a
Merge branch 'main' into feature/array_api_compat_pca
ogrisel c182fbc
Preserve device info svd_flip
ogrisel c72f586
Update array-api-compat version in build_tools/azure/pylatest_conda_f…
ogrisel dcea203
Fix xp.take in sklearn.linear_model by passing axis argument to fit a…
ogrisel 5f38eff
Fix LinearDiscriminantAnalysis.score to work with cupy
ogrisel 41164e9
Test get_covariance / get_precision
ogrisel 8193209
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 42524bd
Typo
ogrisel b45547d
Add comment to explain why we keep the scipy linalg.svd code path for…
ogrisel ee7ab50
Use array_api_compat.to_device
ogrisel 1eb368d
Merge branch 'main' into feature/array_api_compat_pca
ogrisel acdefc0
Improve the to_device helper (with missing docstring)
ogrisel 6c355e6
Use np.newaxis instead of None
ogrisel 5a53dc6
Use _is_numpy_namespace / xp.asarray for all numpy backed xp values
ogrisel e1cf17d
Apply suggestions from code review
ogrisel 1d7b802
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 4dd424b
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 2270b10
Revert no longer needed change to parametrize_with_checks
ogrisel 841d4dc
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 20e0ecf
Leverage broadcasting to sparse a temp allocation
ogrisel 47091b8
Remove changelog merge typo
ogrisel cb5c03f
Keep on using scipy.linalg.inv in PCA.get_covariance by default
ogrisel 4093a6c
Add not on combined dtype conversion and device move
ogrisel 2216276
Spare one more temporary allocation.
ogrisel 5032d1f
Merge branch 'main' into feature/array_api_compat_pca
ogrisel 5abc2bf
Assume to_device is always called under an is_array_api_compliant con…
ogrisel e30bfa8
Extend the common tests to handle the case when array api is used wit…
ogrisel bb564bb
Extend the common tests to handle the case when array api is used wit…
ogrisel 3e28c50
Simplify condition to protect scipy.linalg.svd in randomized_svd
ogrisel ea4fc2e
Merge branch 'main' into feature/array_api_compat_pca
ogrisel b881ff1
Use xp.asarray + device instead of a new to_device helper
ogrisel aa9a33a
Fix randomized_range_finder with sparse matrices
ogrisel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 40 additions & 39 deletions
79
build_tools/azure/pylatest_conda_forge_mkl_linux-64_conda.lock
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is impacted because we now call
float(...)
explicitly on the output ofaccuracy_score
andzero_one_loss
to return a Python scalar instead of 0-dim numpy object whose dtype can vary in hard to predict ways depending on the inputs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the docstring of
accuracy_score
specifies that the return type is float, so this might be considered a bugfix. Not sure if we need a changelog entry for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess no one has noticed this difference till now because the 0-dim numpy array is mostly indistinguishable from a float?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, unless it as an int
dtype
as was the case in this particular code snippet prior to this PR :)