-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Open
Labels
Description
Describe the bug
Running the following script works without a warning in sklearn 1.7, but fails on the latest nightly release. It appears to be related to #31134, but I'm unsure why the issue only became apparent now.
Steps/Code to Reproduce
from sklearn.base import is_regressor
class MyEstimator:
def __init__(self):
...
def fit(self, X, y=None):
self.is_fitted_ = True
return self
def predict(self, X):
...
est = MyEstimator()
is_regressor(est)Expected Results
I would expect the code to continue to run, possibly with a DeprecationWarning.
Actual Results
Traceback (most recent call last):
File "/Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/lib/python3.12/site-packages/sklearn/utils/_tags.py", line 275, in get_tags
tags = estimator.__sklearn_tags__()
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MyEstimator' object has no attribute '__sklearn_tags__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/christian.bourjau/repos/scikit-learn-debug/t.py", line 17, in <module>
is_regressor(est)
File "/Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/lib/python3.12/site-packages/sklearn/base.py", line 1238, in is_regressor
return get_tags(estimator).estimator_type == "regressor"
^^^^^^^^^^^^^^^^^^^
File "/Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/lib/python3.12/site-packages/sklearn/utils/_tags.py", line 283, in get_tags
raise AttributeError(
AttributeError: The following error was raised: 'MyEstimator' object has no attribute '__sklearn_tags__'. It seems that there are no classes that implement `__sklearn_tags__` in the MRO and/or all classes in the MRO call `super().__sklearn_tags__()`. Make sure to inherit from `BaseEstimator` which implements `__sklearn_tags__` (or alternatively define `__sklearn_tags__` but we don't recommend this approach). Note that `BaseEstimator` needs to be on the right side of other Mixins in the inheritance order.
Versions
System:
python: 3.12.11 | packaged by conda-forge | (main, Jun 4 2025, 14:38:53) [Clang 18.1.8 ]
executable: /Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/bin/python
machine: macOS-15.6.1-arm64-arm-64bit
Python dependencies:
sklearn: 1.8.dev0
pip: 25.2
setuptools: 80.9.0
numpy: 2.2.6
scipy: 1.16.0
Cython: 3.1.2
pandas: 3.0.0.dev0+2502.g8476e0f756
matplotlib: None
joblib: 1.5.1
threadpoolctl: 3.6.0
Built with OpenMP: True
threadpoolctl info:
user_api: blas
internal_api: openblas
num_threads: 16
prefix: libopenblas
filepath: /Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/lib/libopenblas.0.dylib
version: 0.3.30
threading_layer: openmp
architecture: VORTEX
user_api: openmp
internal_api: openmp
num_threads: 16
prefix: libomp
filepath: /Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/lib/libomp.dylib
version: None
user_api: openmp
internal_api: openmp
num_threads: 16
prefix: libomp
filepath: /Users/christian.bourjau/repos/scikit-learn-debug/.pixi/envs/nightlies/lib/python3.12/site-packages/sklearn/.dylibs/libomp.dylib
version: None