Skip to content

Update for scikit-learn 1.8.0 and pandas 3.0.0 compatibility#106

Merged
larsoner merged 4 commits intomne-tools:masterfrom
rcmdnk:scikit-learn-v1.8.0
Feb 11, 2026
Merged

Update for scikit-learn 1.8.0 and pandas 3.0.0 compatibility#106
larsoner merged 4 commits intomne-tools:masterfrom
rcmdnk:scikit-learn-v1.8.0

Conversation

@rcmdnk
Copy link
Collaborator

@rcmdnk rcmdnk commented Feb 1, 2026

scikit-learn 1.8.0

In scikit-learn 1.8.0, the private _check_input method was removed from
FunctionTransformer. Instead, validate_data is now called directly inside
FunctionTransformer.fit.

To align with this change, this PR updates:

  • mne_features/feature_extraction.py
    • FeatureFunctionTransformer.fit

so that it calls validate_data directly, mirroring the behavior of
FunctionTransformer.fit in scikit-learn 1.8.0.

This avoids reliance on removed private APIs and ensures forward compatibility.

Note: scikit-learn 1.8.0 was released for Python >= 3.11.


pandas 3.0.0

In pandas 3.0.0, calling X.values on a string-typed column now returns a
pandas.arrays.StringArray instead of a NumPy ndarray.

As a result, numpy.testing.assert_equal no longer works as expected and raises:

ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all().

To ensure correct and stable comparisons across pandas versions, this PR updates
the relevant tests in:

  • mne_features/tests/test_univariate.py

Specifically, occurrences of X.values are replaced with X.to_list(), which
provides a plain Python list and avoids ambiguity when comparing string data.

@rcmdnk rcmdnk marked this pull request as ready for review February 2, 2026 00:28
@bruAristimunha
Copy link

ping @larsoner and @agramfort

import joblib
from sklearn.pipeline import FeatureUnion
from sklearn.preprocessing import FunctionTransformer
from sklearn.utils.validation import validate_data
Copy link
Member

Choose a reason for hiding this comment

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

This is going to lead to an import issue on any version of sklearn that doesn't have this, right? I think over in MNE-Python I figured out this meant 1.6+

https://github.com/mne-tools/mne-python/blob/87d1051d6932383e825ba377b21a221b2670db11/mne/decoding/_fixes.py#L6-L7

Can you add a corresponding pin to >=1.6 to

install_requires=['numpy', 'scipy', 'numba', 'scikit-learn', 'mne',

@rcmdnk
Copy link
Collaborator Author

rcmdnk commented Feb 11, 2026

@larsoner
Thanks for pointing this out.
I've now updated requirements in environment.yml/setup.py to scikit-learn>=1.6.

@larsoner larsoner merged commit 3079414 into mne-tools:master Feb 11, 2026
7 checks passed
@rcmdnk rcmdnk deleted the scikit-learn-v1.8.0 branch February 17, 2026 06:03
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.

3 participants