FIX Fix ColumnTransformer.get_feature_names_out with slices - #22775
Conversation
adrinjalali
left a comment
There was a problem hiding this comment.
Please also add a regression test (to test the new behavior does what it should), and add a what_new entry under the 1.1 version.
ogrisel
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix and the non-regression test!
thomasjpfan
left a comment
There was a problem hiding this comment.
Thank you for the PR! I left minor comments on adjust the tests to test slices with more than one element.
| ( | ||
| [ | ||
| ("bycol1", TransWithNames(), slice(1, 2)), | ||
| ("bycol2", "drop", ["d"]), | ||
| ], | ||
| "passthrough", | ||
| ["bycol1__b", "remainder__a", "remainder__c"], | ||
| ), |
There was a problem hiding this comment.
May we update this example to have a slice with more than one element?
(
[
("bycol1", TransWithNames(), slice(1, 3)),
],
"drop",
["bycol1__b", "bycol1__c"],
),| [ | ||
| ("bycol1", TransWithNames(), ["d", "c"]), | ||
| ("bycol2", "passthrough", slice(0, 1)), | ||
| ], | ||
| "drop", | ||
| ["d", "c", "a"], |
There was a problem hiding this comment.
Same here regarding slicing with more than one element:
| [ | |
| ("bycol1", TransWithNames(), ["d", "c"]), | |
| ("bycol2", "passthrough", slice(0, 1)), | |
| ], | |
| "drop", | |
| ["d", "c", "a"], | |
| [ | |
| ("bycol1", TransWithNames(), ["d", "c"]), | |
| ("bycol2", "passthrough", slice(0, 2)), | |
| ], | |
| "drop", | |
| ["d", "c", "a", "b"], |
There was a problem hiding this comment.
@ogrisel @thomasjpfan Thanks for your feedback. I have pushed another commit incorporating your suggestions. Tx
Reference Issues/PRs
Fixes #22774
What does this implement/fix? Explain your changes.
Currently, ColumnTransformer's get_feature_names_out does not work when the columns are specified as slices. This fix makes get_feature_names_out work properly with slices as well.
Any other comments?