Closed
Description
Describe the bug
The estimator tags for sklearn.linear_model.LogisticRegression
are wrong because the _get_tags
method uses the following resolution order for this estimator:
from sklearn.linear_model import LogisticRegression
import inspect
list(reversed(inspect.getmro(LogisticRegression)))
[<class 'object'>, <class 'sklearn.linear_model._base.SparseCoefMixin'>, <class 'sklearn.base.ClassifierMixin'>, <class 'sklearn.linear_model._base.LinearClassifierMixin'>, <class 'sklearn.base.BaseEstimator'>, <class 'sklearn.linear_model._logistic.LogisticRegression'>]
Thus, sklearn.base.BaseEstimator
is replacing the estimator tags defined in sklearn.base.ClassifierMixin
(e.g., requires_y
).
Steps/Code to Reproduce
from sklearn.linear_model import LogisticRegression
LogisticRegression()._get_tags()
{'requires_y': False, 'non_deterministic': False, 'requires_positive_X': False, 'requires_positive_y': False, 'X_types': ['2darray'], 'poor_score': False, 'no_validation': False, 'multioutput': False, 'allow_nan': False, 'stateless': False, 'multilabel': False, '_skip_test': False, '_xfail_checks': False, 'multioutput_only': False, 'binary_only': False, 'requires_fit': True}
Expected Results
{'requires_y': True, 'non_deterministic': False, 'requires_positive_X': False, 'requires_positive_y': False, 'X_types': ['2darray'], 'poor_score': False, 'no_validation': False, 'multioutput': False, 'allow_nan': False, 'stateless': False, 'multilabel': False, '_skip_test': False, '_xfail_checks': False, 'multioutput_only': False, 'binary_only': False, 'requires_fit': True}
Actual Results
{'requires_y': False, 'non_deterministic': False, 'requires_positive_X': False, 'requires_positive_y': False, 'X_types': ['2darray'], 'poor_score': False, 'no_validation': False, 'multioutput': False, 'allow_nan': False, 'stateless': False, 'multilabel': False, '_skip_test': False, '_xfail_checks': False, 'multioutput_only': False, 'binary_only': False, 'requires_fit': True}
Versions
import sklearn; sklearn.show_versions()
System:
python: 3.6.10 (default, Jun 9 2020, 18:45:00) [GCC 8.3.0]
executable: /usr/local/bin/python
machine: Linux-4.19.76-linuxkit-x86_64-with-debian-10.4
Python dependencies:
pip: 20.1.1
setuptools: 47.1.1
sklearn: 0.24.dev0
numpy: 1.18.4
scipy: 1.4.1
Cython: 0.29.18
pandas: 1.0.3
matplotlib: 3.2.1
joblib: 0.15.1
threadpoolctl: 2.0.0
Built with OpenMP: True