Skip to content

Handle single sample output from FeatureFunctionTransformer to support scikit-learn 1.7.2 and later#97

Merged
jbschiratti merged 1 commit intomne-tools:masterfrom
rcmdnk:fix_transform_output
Oct 17, 2025
Merged

Handle single sample output from FeatureFunctionTransformer to support scikit-learn 1.7.2 and later#97
jbschiratti merged 1 commit intomne-tools:masterfrom
rcmdnk:fix_transform_output

Conversation

@rcmdnk
Copy link
Collaborator

@rcmdnk rcmdnk commented Oct 14, 2025

From scikit-learn 1.7.2, transformers used within FeatureUnion are required to return 2-dimensional outputs instead of 1-dimensional ones.
See the release notes:
https://scikit-learn.org/stable/whats_new/v1.7.html#sklearn-pipeline

Since all compute_ functions return 1-D arrays, extract_features now raises an error such as:

ValueError: Transformer 'mean' returned an array or dataframe with 1 dimensions, but expected 2 dimensions (n_samples, n_features).

This PR fixes the output dimension of FeatureFunctionTransformer.transform to always be 2-D, rather than modifying each compute_ function.
This approach allows users to keep their custom feature-extraction functions unchanged.

@rcmdnk
Copy link
Collaborator Author

rcmdnk commented Oct 15, 2025

Tests don't start because the GitHub Actions workflow is outdated.
They will start after #99 is merged.

Copy link
Collaborator

@jbschiratti jbschiratti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @rcmdnk for fixing this! Feel free to merge it

@rcmdnk
Copy link
Collaborator Author

rcmdnk commented Oct 17, 2025

@hubertjb (sorry for the wrong mention)
Thank you for the review.

It seems I don’t have the permission to merge this PR.
Could you please merge it for me?

@jbschiratti jbschiratti merged commit 9095221 into mne-tools:master Oct 17, 2025
0 of 2 checks passed
rcmdnk added a commit to rcmdnk/mne-features that referenced this pull request Oct 19, 2025
@rcmdnk rcmdnk deleted the fix_transform_output branch October 21, 2025 00:51
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 this pull request may close these issues.

2 participants