-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
Initially mis-reported as a scikit-learn bug:
The following code errored while benchmarking and I couldn’t tell why: it turned out to be because Picard is overriding the underlying FastICA options(?)
picard/picard/dropin_sklearn.py
Lines 108 to 112 in bbeba2a
| # update parameters constraint dict | |
| self._parameter_constraints["fun"] = [ | |
| StrOptions({"tanh", "exp", "cube"}), | |
| callable, | |
| ] |
import numpy as np
from picard import Picard
from sklearn.decomposition import FastICA
X = np.random.randn(1000, 384)
ica = Picard(n_components=10, random_state=42)
ica.fit_transform(X)
ica_sklearn = FastICA(n_components=10, random_state=42)
ica_sklearn.fit_transform(X)
File "/home/louis/dev/arxiv_explorer/benchmark_ica_impls.py", line 84, in <module>
S_sklearn = ica_sklearn.fit_transform(X_whitened2)
File "/home/louis/dev/arxiv_explorer/.venv/lib/python3.13/site-packages/sklearn/utils/_set_output.py", line 316, in wrapped
data_to_wrap = f(self, X, *args, **kwargs)
File "/home/louis/dev/arxiv_explorer/.venv/lib/python3.13/site-packages/sklearn/base.py", line 1329, in wrapper
estimator._validate_params()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/louis/dev/arxiv_explorer/.venv/lib/python3.13/site-packages/sklearn/base.py", line 492, in _validate_params
validate_parameter_constraints(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
self._parameter_constraints,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.get_params(deep=False),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
caller_name=self.__class__.__name__,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/louis/dev/arxiv_explorer/.venv/lib/python3.13/site-packages/sklearn/utils/_param_validation.py", line 98, in validate_parameter_constraints
raise InvalidParameterError(
...<2 lines>...
)
sklearn.utils._param_validation.InvalidParameterError: The 'fun' parameter of FastICA must be a str among {'exp', 'cube', 'tanh'} or a callable. Got 'logcosh' instead.
Note that in this code the fun parameter is not passed, the FastICA is rendered unusable because of the modification Picard executes.
Metadata
Metadata
Assignees
Labels
No labels