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

Skip to content

RandomTreesEmbedding.transform fails unhelpfully #12959

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

Closed
finnoshea opened this issue Jan 11, 2019 · 1 comment · Fixed by #12965
Closed

RandomTreesEmbedding.transform fails unhelpfully #12959

finnoshea opened this issue Jan 11, 2019 · 1 comment · Fixed by #12965

Comments

@finnoshea
Copy link
Contributor

finnoshea commented Jan 11, 2019

sklearn: 0.20.0

When running a transform from an untrained RandomTreesEmbedding class, the failure message isn't helpful:

return self.one_hot_encoder_.transform(self.apply(X))
AttributeError: 'RandomTreesEmbedding' object has no attribute 'one_hot_encoder_'

This is because the method RandomTreesEmbedding.transform doesn't check for the existence of the fit before performing the transform. Since forest.py imports check_is_fitted, I think this can be solved by changing the method to add the line check_is_fitted(self, 'one_hot_encoder_') just before the return statement (the only line of code in the transform method).

I can do this and put in a pull request, if you like.

@rth
Copy link
Member

rth commented Jan 12, 2019

Yes, thanks for the report and the fix. A more general issue for this (that also might apply to other estimators) is #12967

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 a pull request may close this issue.

2 participants