Closed
Description
Describe the bug
Support for is_regressor
and is_classifier
is deprecated with scikit-learn 1.6.0
, see Release notes and scikit-learn/scikit-learn#30122
Minimum reproducible code snippet
https://docs.doubleml.org/stable/examples/py_double_ml_pension.html
see failing job https://github.com/DoubleML/doubleml-docs/actions/runs/12273024534/job/34242980869
Expected Result
sucessful execution
Actual Result
AttributeError Traceback (most recent call last)
Cell In[21], line 9
4 boost_class = XGBClassifier(use_label_encoder=False, n_jobs=1,
5 objective = "binary:logistic", eval_metric = "logloss",
6 eta=0.1, n_estimators=34)
8 np.random.seed(123)
----> 9 dml_plr_boost = dml.DoubleMLPLR(data_dml_base,
10 ml_l = boost,
11 ml_m = boost_class,
12 n_folds = 3)
13 dml_plr_boost.fit(store_predictions=True)
14 boost_summary = dml_plr_boost.summary
File ~/work/doubleml-docs/doubleml-docs/doubleml-for-py/doubleml/plm/plr.py:111, in DoubleMLPLR.__init__(self, obj_dml_data, ml_l, ml_m, ml_g, n_folds, n_rep, score, draw_sample_splitting)
108 valid_scores = ['IV-type', 'partialling out']
109 _check_score(self.score, valid_scores, allow_callable=True)
--> 111 _ = self._check_learner(ml_l, 'ml_l', regressor=True, classifier=False)
112 ml_m_is_classifier = self._check_learner(ml_m, 'ml_m', regressor=True, classifier=True)
113 self._learner = {'ml_l': ml_l, 'ml_m': ml_m}
File ~/work/doubleml-docs/doubleml-docs/doubleml-for-py/doubleml/double_ml.py:906, in DoubleML._check_learner(learner, learner_name, regressor, classifier)
904 else:
905 assert regressor # classifier, regressor or both must be True
--> 906 if not is_regressor(learner):
907 warnings.warn(warn_msg_prefix + f'{str(learner)} is (probably) no regressor.')
908 learner_is_classifier = False
File /opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/sklearn/base.py:1277, in is_regressor(estimator)
1270 warnings.warn(
1271 f"passing a class to {print(inspect.stack()[0][3])} is deprecated and "
1272 "will be removed in 1.8. Use an instance of the class instead.",
1273 FutureWarning,
1274 )
1275 return getattr(estimator, "_estimator_type", None) == "regressor"
-> 1277 return get_tags(estimator).estimator_type == "regressor"
File /opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/sklearn/utils/_tags.py:405, in get_tags(estimator)
403 for klass in reversed(type(estimator).mro()):
404 if "__sklearn_tags__" in vars(klass):
--> 405 sklearn_tags_provider[klass] = klass.__sklearn_tags__(estimator) # type: ignore[attr-defined]
406 class_order.append(klass)
407 elif "_more_tags" in vars(klass):
File /opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/sklearn/base.py:613, in RegressorMixin.__sklearn_tags__(self)
612 def __sklearn_tags__(self):
--> 613 tags = super().__sklearn_tags__()
614 tags.estimator_type = "regressor"
615 tags.regressor_tags = RegressorTags()
AttributeError: 'super' object has no attribute '__sklearn_tags__'
Versions
See https://github.com/DoubleML/doubleml-docs/actions/runs/12273024534/job/34242980869