Skip to content

Regressor validation with scikit-learn ≥ 1.6 #11

Description

@NGC2023

Hi,
I have created a patch to address the AttributeError with scikit-learn ≥ 1.6 new tag system.

--- a/skopt/optimizer/optimizer.py
+++ b/skopt/optimizer/optimizer.py
@@ -253,8 +253,13 @@ class Optimizer:
             )
 
         # check if regressor
-        if not is_regressor(base_estimator) and base_estimator is not None:
-            raise ValueError("%s has to be a regressor." % base_estimator)
+        if base_estimator is not None and not isinstance(base_estimator, str):
+            try:
+                ok = is_regressor(base_estimator)
+            except Exception:
+                ok = False
+            if not ok:
+                raise ValueError("base_estimator has to be a regressor.")
 
         # treat per second acqusition function specially
         is_multi_regressor = isinstance(base_estimator, MultiOutputRegressor)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions