Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX Add check array for empirical_covariance - #26108

Merged
jeremiedbb merged 7 commits into
scikit-learn:mainfrom
qbarthelemy:covariance_ecm_checkarray
May 23, 2023
Merged

FIX Add check array for empirical_covariance#26108
jeremiedbb merged 7 commits into
scikit-learn:mainfrom
qbarthelemy:covariance_ecm_checkarray

Conversation

@qbarthelemy

@qbarthelemy qbarthelemy commented Apr 5, 2023

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #25519

What does this implement/fix? Explain your changes.

It adds check_array to empirical_covariance.

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @qbarthelemy. We don't need it for _oas because it's a private function only called by OAS which already validates X.

Comment thread sklearn/covariance/_shrunk_covariance.py Outdated
Co-authored-by: Jérémie du Boisberranger <[email protected]>
@qbarthelemy qbarthelemy changed the title FIX Add check array for empirical_covariance and _oas FIX Add check array for empirical_covariance Apr 6, 2023

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about that again, I think it deserves an entry in the changelog. Please add an entry in v1.3.rst, saying that now empirical_covariance gives an informative error message when input is not appropriate.

Comment thread sklearn/covariance/_empirical_covariance.py Outdated
qbarthelemy and others added 2 commits April 7, 2023 16:36

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Than you for the PR!

Comment thread sklearn/covariance/_empirical_covariance.py Outdated
Comment thread doc/whats_new/v1.3.rst Outdated
Comment thread sklearn/covariance/_empirical_covariance.py Outdated
@qbarthelemy
qbarthelemy force-pushed the covariance_ecm_checkarray branch from 354b832 to f75cb70 Compare May 1, 2023 14:34
qbarthelemy and others added 2 commits May 1, 2023 16:35
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update! LGTM

[0.25, 0.25, 0.25]])
"""
X = np.asarray(X)
X = check_array(X, ensure_2d=False, force_all_finite=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers, I think it's okay to set force_all_finite=False here, which is consistent with the behavior on main. If we set force_all_finite=True, then there can be a performance regression when empirical_covariance is called. The alternative is to set config_context(assume_finite=True) everywhere, but it adds the context manager to many places.

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @qbarthelemy

@jeremiedbb
jeremiedbb enabled auto-merge (squash) May 23, 2023 12:38
@jeremiedbb
jeremiedbb merged commit f034f57 into scikit-learn:main May 23, 2023
@qbarthelemy
qbarthelemy deleted the covariance_ecm_checkarray branch May 23, 2023 14:02
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

empirical_covariance silently returns invalid results on inputs with a complex dtype

3 participants