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

Skip to content

Fix to inelegant failure of RandomTreesEmbedding.transform when not fitted #12965

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

Conversation

finnoshea
Copy link
Contributor

RandomTreesEmbedding.transform fails with a message about .one_hot_encoder_ missing when it hasn't first been fit. This message doesn't tell the user what to do to fix the problem. I've added a check for .one_hot_encoder_ using the standard check_is_fitted method that is used by most other classes with a fit and predict/transform. This should make it clear that the instance isn't yet fit.

Fixes #12959

What does this implement/fix? Explain your changes.

The current error message that comes from use of a non-fitted RandomTreesEmbedding.transform doesn't help the user locate the problem. I've added a check_is_fitted() call just before the transform call to check if the fit has been performed and otherwise tell the user to do a fit first.

Any other comments?

This code and community is awesome.

…coder_ missing when it hasn't first been fit. This message doesn't tell the user what to do to fix the problem. I've added a check for .one_hot_encoder_ using the standard check_is_fitted method that is used by most other classes with a fit and predict/transform. This should make it clear that the instance isn't yet fit.
Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks @finnoshea, LGTM.

Copy link
Member

@qinhanmin2014 qinhanmin2014 left a comment

Choose a reason for hiding this comment

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

thanks @finnoshea
I think we'll rely on a common test to test these things.

@qinhanmin2014 qinhanmin2014 merged commit 98baafb into scikit-learn:master Jan 13, 2019
@finnoshea finnoshea deleted the RandomTreesEmbeddingBugFix branch January 13, 2019 20:27
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RandomTreesEmbedding.transform fails unhelpfully
3 participants