Skip to content
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

ENH Check for nonfinite in mlp models #22150

Merged
merged 9 commits into from Jan 19, 2022

Conversation

chritter
Copy link
Contributor

@chritter chritter commented Jan 8, 2022

Reference Issues/PRs

Addresses #17925.

What does this implement/fix? Explain your changes.

This implements check for non-finite values of estimator parameters: as produced from optimizers in MLP models.

Any other comments?

Work done with @norbusan.

Originally part of larger PR #22092

@chritter chritter changed the title test for nonfinite in mlp models [MRG] test for nonfinite in mlp models Jan 8, 2022
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @chritter !

sklearn/neural_network/tests/test_mlp.py Outdated Show resolved Hide resolved
sklearn/neural_network/_multilayer_perceptron.py Outdated Show resolved Hide resolved
for coef, inter in zip(self.coefs_, self.intercepts_)
]
):
raise ValueError("Solver produced non-finite parameter weights.")
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment from https://github.com/scikit-learn/scikit-learn/pull/22149/files#r780722680 We can adjust the message so users know what they can do about it.

Suggested change
raise ValueError("Solver produced non-finite parameter weights.")
raise ValueError("coefs or intercepts have non-finite parameter weights. "
"The input data may contain large values and need to be "
"preprocessed.")

Copy link
Member

Choose a reason for hiding this comment

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

May you include the second part of the message?

Copy link
Member

Choose a reason for hiding this comment

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

May you include the second part of the error message?

Co-authored-by: Norbert Preining <norbert@preining.info>
chritter and others added 3 commits January 14, 2022 13:55
test_nonfinite_params test data now generated; test parameter in mlp with itertools

Co-authored-by: Norbert Preining <norbert@preining.info>
@chritter
Copy link
Contributor Author

Great suggestions @thomasjpfan which I adopted. Thank you!

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

:mod:`sklearn.neural_network`
.............................
Copy link
Member

Choose a reason for hiding this comment

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

Nit: May we move this header up such that the modules are in alphabetical order?

for coef, inter in zip(self.coefs_, self.intercepts_)
]
):
raise ValueError("Solver produced non-finite parameter weights.")
Copy link
Member

Choose a reason for hiding this comment

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

May you include the second part of the message?

@thomasjpfan thomasjpfan changed the title [MRG] test for nonfinite in mlp models ENH Check for nonfinite in mlp models Jan 15, 2022
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

for coef, inter in zip(self.coefs_, self.intercepts_)
]
):
raise ValueError("Solver produced non-finite parameter weights.")
Copy link
Member

Choose a reason for hiding this comment

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

May you include the second part of the error message?

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

I left a minor comment, otherwise LGTM!

@@ -462,6 +470,7 @@ Changelog
left corner of the HTML representation to show how the elements are
clickable. :pr:`21298` by `Thomas Fan`_.


Copy link
Member

Choose a reason for hiding this comment

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

This change is unrelated. Can you revert?

Copy link
Contributor Author

@chritter chritter Jan 17, 2022

Choose a reason for hiding this comment

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

@Thomas9292 This change entry was not introduced in this PR, so I believe no change is needed. Could you clarify?

Note that

- |Enhancement| :func:`utils.estimator_html_repr` displays an arrow on the top
  left corner of the HTML representation to show how the elements are
  clickable. :pr:`21298` by `Thomas Fan`_.

is a unique entry.

Copy link
Member

Choose a reason for hiding this comment

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

There is an extra newline added here.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's the GitHub interface. I am referring to this newline added by this PR:

Screen Shot 2022-01-17 at 9 02 06 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the clarification.

@thomasjpfan thomasjpfan added the Quick Review For PRs that are quick to review label Jan 15, 2022
Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

LGTM after addressing @thomasjpfan's comments.

doc/whats_new/v1.1.rst Outdated Show resolved Hide resolved
sklearn/neural_network/tests/test_mlp.py Outdated Show resolved Hide resolved
@jjerphan jjerphan removed the Quick Review For PRs that are quick to review label Jan 18, 2022
chritter and others added 2 commits January 18, 2022 20:32
improved changelog description

Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
@chritter
Copy link
Contributor Author

@jjerphan Thank you for the review and for the suggestions. Adopted.

@jjerphan jjerphan merged commit 9816b35 into scikit-learn:main Jan 19, 2022
29 checks passed
mathijs02 pushed a commit to mathijs02/scikit-learn that referenced this pull request Dec 27, 2022
* non-finite check in mlp params.

Co-authored-by: Norbert Preining <norbert@preining.info>

* added changelog entry

* updated changelog

* simplied nonfinite param check and test;

test_nonfinite_params test data now generated; test parameter in mlp with itertools

Co-authored-by: Norbert Preining <norbert@preining.info>

* reformatting test file

* update changelog formatting to pass circleci check

* update changelog location alphabetic, extended error message and test

* removed empty line in whatsnew

* Apply suggestions from code review

improved changelog description

Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>

Co-authored-by: Norbert Preining <norbert@preining.info>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
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.

None yet

3 participants