Skip to content

RandomTreesEmbedding.transform fails unhelpfully #12959

@finnoshea

Description

@finnoshea

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions