Skip to content
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

[ENH] __getitem__ aka [ ] dunder for transformers, column subsetting #2907

Merged
merged 93 commits into from Jul 26, 2022

Conversation

fkiraly
Copy link
Collaborator

@fkiraly fkiraly commented Jul 1, 2022

This PR adds column subsetting functionality to transformers via the [ ] (__getitem__) dunder.

Similar to how this works in pywatts, using the [ ] dunder will change any transformer to additionally subsetting columns of outputs (first key) and/or inputs (second key).
This is done by pipelining with the existing ColumnSelect transformer, using the existing TransformerPipeline.

Examples:
my_trafo["a"] is shorthand for ColumnSelect("a") * my_trafo, which in turn is shorthand for TransformerPipeline([ColumnSelect("a"), my_trafo])
my_trafo[idx1, idx2] is shorthand for ColumnSelect(idx1) * my_trafo * ColumnSelect(idx2), which in turn is shorthand for TransformerPipeline([ColumnSelect(idx1), my_trafo, ColumnSelect(idx2)])

Includes tests.

Relies on:

Credit to pywatts for the idea - thanks, @benHeid, @SMEISEN, @kalebphipps!

Also see discussion here: #2654

@fkiraly fkiraly added module:transformations transformations module: time series transformation, feature extraction, pre-/post-processing enhancement Adding new functionality labels Jul 1, 2022
@fkiraly fkiraly requested a review from aiwalter as a code owner July 1, 2022 18:45
@fkiraly
Copy link
Collaborator Author

fkiraly commented Jul 1, 2022

Credit to pywatts for the idea - thanks, @benHeid, @SMEISEN, @kalebphipps!

Also see discussion here: #2654

@fkiraly fkiraly added this to In progress in Graphpipeline (sktime-pywatts) Jul 3, 2022
@fkiraly fkiraly moved this from In progress to Done in Graphpipeline (sktime-pywatts) Jul 3, 2022
@fkiraly fkiraly moved this from Done to Under review in Graphpipeline (sktime-pywatts) Jul 3, 2022
@fkiraly fkiraly self-assigned this Jul 3, 2022
@fkiraly fkiraly requested a review from mloning as a code owner July 9, 2022 17:17
@fkiraly fkiraly merged commit e4c36af into main Jul 26, 2022
@fkiraly fkiraly deleted the getitem-dunder branch July 26, 2022 18:21
@fkiraly fkiraly moved this from Under review to Done in Graphpipeline (sktime-pywatts) Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality module:transformations transformations module: time series transformation, feature extraction, pre-/post-processing
Development

Successfully merging this pull request may close these issues.

None yet

2 participants