FLAML icon indicating copy to clipboard operation
FLAML copied to clipboard

[Bug]: AutoML(task="classification") is not detected as a classifier by scikit learns

Open lepennec opened this issue 4 months ago • 4 comments

Describe the bug

scikit learn has a is_classifier function that is used internally to detect whether the object is a classifier or not. It fails with AutoML(task="classifier"). More precisely, the __sklearn_tags__ method that is used in is_classifier returns a set of tags in which estimator_type ìs set to None, while getattr(AutoML(task="classifier"), "_estimator_type", None)|

I have stumbled on this issue while using a custom scorer which raises an error.

Finally, there is the same issue with the regression task which fails to be detected as a regressor by is_regressor

Steps to reproduce

from flaml import AutoML
from sklearn.base import is_classifier

is_classifier(AutoML(task="classifier")

AutoML(task="classifier").__sklearn_tags()

getattr(AutoML(task="classifier"), "_estimator_type", None)

Model Used

No response

Expected Behavior

AutoML(task="classifier") should be detected as a classifier.

Screenshots and logs

No response

Additional Information

FLAML Version : 2.3.6 Colab with Python 3.12.11

lepennec avatar Aug 29 '25 08:08 lepennec

Hi @lepennec , there is no task "classifier". Please use "classification" instead. https://microsoft.github.io/FLAML/docs/Use-Cases/Task-Oriented-AutoML

Thanks.

thinkall avatar Aug 30 '25 03:08 thinkall

Btw, python 3.12 is not fully tested yet. Use python 3.11 or 3.10 if possible.

thinkall avatar Aug 30 '25 03:08 thinkall

Sorry for the error in the code. I was using "classification" in my code, but I rewrote it with an error above. The issue is still here with

from flaml import AutoML
from sklearn.base import is_classifier

is_classifier(AutoML(task="classification")

AutoML(task="classification").__sklearn_tags()

getattr(AutoML(task="classification"), "_estimator_type", None)

lepennec avatar Sep 01 '25 12:09 lepennec

Sorry for the error in the code. I was using "classification" in my code, but I rewrote it with an error above. The issue is still here with

from flaml import AutoML
from sklearn.base import is_classifier

is_classifier(AutoML(task="classification")

AutoML(task="classification").__sklearn_tags()

getattr(AutoML(task="classification"), "_estimator_type", None)

Thanks for the clarification, @lepennec .

Image

There is no __sklearn_tags() because this was made public in scikit-learn 1.6.0, so FLAML didn't add this to the estimators. But it's a classifier.

thinkall avatar Sep 05 '25 08:09 thinkall