Closed
Description
Describe the bug
In the latest release (v1.6.0), cross_validate
raises an exception when using it with metadata routing enabled. This is because params
dict gets unpacked even if None
, which is the default value. See this line:
Steps/Code to Reproduce
import numpy as np
import sklearn
from sklearn.model_selection import cross_validate
from sklearn.model_selection.tests.test_validation import MockClassifier
sklearn.set_config(enable_metadata_routing=True)
X = np.ones((10, 2))
y = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4])
clf = MockClassifier()
cross_validate(clf, X, y)
Expected Results
No exception being raised.
Actual Results
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<redacted>/lib/python3.10/site-packages/sklearn/utils/_param_validation.py", line 216, in wrapper
return func(*args, **kwargs)
File "<redacted>/lib/python3.10/site-packages/sklearn/model_selection/_validation.py", line 375, in cross_validate
routed_params = process_routing(router, "fit", **params)
TypeError: sklearn.utils._metadata_requests.process_routing() argument after ** must be a mapping, not NoneType
Versions
System:
python: 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0]
executable: <redacted>/bin/python
machine: Linux-6.5.13netflix-g77293087f291-x86_64-with-glibc2.35
Python dependencies:
sklearn: 1.6.0
pip: None
setuptools: 75.6.0
numpy: 1.26.4
scipy: 1.14.1
Cython: None
pandas: 2.2.3
matplotlib: 3.9.3
joblib: 1.4.2
threadpoolctl: 3.5.0
Built with OpenMP: True
threadpoolctl info:
user_api: blas
internal_api: openblas
num_threads: 4
prefix: libopenblas
filepath: /root/pycharm_projects/evaluations/.venv/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so
version: 0.3.23.dev
threading_layer: pthreads
architecture: Cooperlake
user_api: blas
internal_api: openblas
num_threads: 4
prefix: libscipy_openblas
filepath: /root/pycharm_projects/evaluations/.venv/lib/python3.10/site-packages/scipy.libs/libscipy_openblas-c128ec02.so
version: 0.3.27.dev
threading_layer: pthreads
architecture: Cooperlake
user_api: openmp
internal_api: openmp
num_threads: 4
prefix: libgomp
filepath: <redacted>/lib/python3.10/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
version: None