Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add additional validation for user-supplied gram matrixes #19004

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
merged 11 commits into from
Jan 5, 2021

Conversation

amidvidy
Copy link
Contributor

Reference Issues/PRs

#18973

What does this implement/fix? Explain your changes.

  1. Adds additional validation check for precomputed gram matrix suggested by @agramfort.
  2. Adds tests for the above check,
  3. Adds a new example illustrating how to correctly compute gram matrix when sample weights are also supplied.

Any other comments?

Thanks in advance for reviewing.

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

thx @amidvidy

sklearn/linear_model/tests/test_coordinate_descent.py Outdated Show resolved Hide resolved
sklearn/utils/validation.py Outdated Show resolved Hide resolved
@amidvidy
Copy link
Contributor Author

i believe I have resolved the above comments @agramfort

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

I did a first pass.

Please add an entry to the change log at doc/whats_new/v*.rst. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:.

sklearn/utils/validation.py Outdated Show resolved Hide resolved
sklearn/utils/validation.py Outdated Show resolved Hide resolved
sklearn/utils/validation.py Outdated Show resolved Hide resolved
sklearn/utils/validation.py Outdated Show resolved Hide resolved
sklearn/utils/validation.py Outdated Show resolved Hide resolved
@amidvidy
Copy link
Contributor Author

thanks for the review @glemaitre. I believe I have resolved your comments, with the exception the calls to .copy() in the unit test, for which I have filed #19044.

@amidvidy
Copy link
Contributor Author

#19044 was resolved, so will update test and rebase.

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

A couple of last changes

X : ndarray of shape (n_samples, n_features)
Data array.

precompute: array-like of shape (n_features, n_features)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
precompute: array-like of shape (n_features, n_features)
precompute : array-like of shape (n_features, n_features)

Copy link
Member

Choose a reason for hiding this comment

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

I assume that precompute should be an ndarray and not an array-like as specified in the docstring.

Copy link
Contributor Author

@amidvidy amidvidy Jan 5, 2021

Choose a reason for hiding this comment

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

in the docstring for the ElasticNet constructor, the precompute param is also specified as array-like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i've kept it as array-like for consistency, perhaps it should be updated in both places?

sklearn/linear_model/_base.py Show resolved Hide resolved
@amidvidy
Copy link
Contributor Author

amidvidy commented Jan 5, 2021

the test failures on this latest commit seem to be related to #19096.

@glemaitre
Copy link
Member

the test failures on this latest commit seem to be related to #19096.

Yes it should be fixed pretty soon. We can just discard it.

@glemaitre glemaitre merged commit 2d95acf into scikit-learn:master Jan 5, 2021
@glemaitre
Copy link
Member

Thanks @amidvidy. Good to be merged.

@amidvidy
Copy link
Contributor Author

amidvidy commented Jan 5, 2021

Thanks again for the help with this PR @glemaitre & @agramfort

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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.