Skip to content

column transformer assumes elements of get_feature_names() will be strings. #16093

Closed
@mguptawork

Description

@mguptawork

Description

To me this looks like a really simple fix:
At line https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/compose/_column_transformer.py#L364
the get_feature_names function in column_transformer assumes all the transformers will provide elements of type string. I think the fix could be something as simple as rewriting the code to be.
feature_names.extend([name + "__" + str(f) for f in trans.get_feature_names()])
ie f has str wrapped around it.

Not all sklearn components such as the DictVectorizer guarantee the elements of get_feature_names() will be strings so this seems like a good addition.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions