Skip to content

AdaBoost: deprecation of "base_estimator" does not handle "base_estimator=None" setting properly #26241

@markotoplak

Description

@markotoplak

Describe the bug

Scikit-learn 1.2 deprecated AdaBoostClassifier 's base_estimator in favour of estimator (see #23819). Because there are also validators in place, old code that explicitly defined base_estimator=None stopped working.

A solution that fixes the deprecation is to add a possible None to a list allowed values in _parameter_constraints; I will do that in a PR.

Steps/Code to Reproduce

from sklearn.ensemble import AdaBoostClassifier
clf = AdaBoostClassifier(base_estimator=None)
clf.fit([[1]], [0])

Expected Results

No error is thrown.

Actual Results

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/marko/opt/miniconda3/envs/orange310/lib/python3.10/site-packages/sklearn/ensemble/_weight_boosting.py", line 124, in fit
    self._validate_params()
  File "/Users/marko/opt/miniconda3/envs/orange310/lib/python3.10/site-packages/sklearn/base.py", line 600, in _validate_params
    validate_parameter_constraints(
  File "/Users/marko/opt/miniconda3/envs/orange310/lib/python3.10/site-packages/sklearn/utils/_param_validation.py", line 97, in validate_parameter_constraints
    raise InvalidParameterError(
sklearn.utils._param_validation.InvalidParameterError: The 'base_estimator' parameter of AdaBoostClassifier must be an object implementing 'fit' and 'predict' or a str among {'deprecated'}. Got None instead.

Versions

sklearn: 1.2.2; others are not important

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions