You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
Version incompatibility with latest scikit-learn. #902
When I run this example, I get the following output:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
20 )
21
---> 22 opt.fit(X_train, y_train)
23
24 print("val. score: %s" % opt.best_score_)
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/skopt/searchcv.py in fit(self, X, y, groups, callback)
678 optim_result = self._step(
679 X, y, search_space, optimizer,
--> 680 groups=groups, n_points=n_points_adjusted
681 )
682 n_iter -= n_points
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/skopt/searchcv.py in _step(self, X, y, search_space, optimizer, groups, n_points)
564 refit = self.refit
565 self.refit = False
--> 566 self._fit(X, y, groups, params_dict)
567 self.refit = refit
568
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/skopt/searchcv.py in _fit(self, X, y, groups, parameter_iterable)
477 # `"param_%s" % name` at the first occurence of `name`.
478 # Setting the value at an index also unmasks that index
--> 479 param_results["param_%s" % name][cand_i] = value
480
481 results.update(param_results)
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/sklearn/utils/deprecation.py in wrapped(*args, **kwargs)
66 def wrapped(*args, **kwargs):
67 warnings.warn(msg, category=FutureWarning)
---> 68 return init(*args, **kwargs)
69 cls.__init__ = wrapped
70
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
If I downgrade scikit-learn back to 0.23.0 and do the monkey patch as described above, everything works ok.
Reacted by Szymon Wojciechowski, Serg Pokrovskyy, sobayed, Deancup, Omar Ali Sheikh-Omar, Quan Gu, Jaehun Kim, Anand , Rich Huang, Young Jin Kim and 1 more
scikit-learn==0.23.1 does solve this for now.
they did properly deprecate the failing option now instead of simply removing:
source: scikit-learn/scikit-learn#17199
I added the information about TypeError: object.__init__() takes exactly one argument as it is part of scikit-optimize not being compatible with the most recent scikit-learn. Additionally some comments above said that the newest scikit-learn should remove the need for monkey patching. If it is preferred I can open a new issue (if the issue still exists).
I think this is actually part of the original issue as it was meant to be a fix, but I think there's an issue with the fix. If you want to look into it, I think we should fix it in sklearn.
I am using scikit-survival for building CoxPH survival model and BayesSearchCV for tunning, however, I have error TypeError: object.__init__() takes no parameters when I try to run BayesSearchCV(estimator=CoxPHSurvivalAnalysis(), search_spaces=params_coxph, cv=10, n_jobs=-1).fit(X_train, y_train). How to solve this?
Activity
Innixma commentedon May 12, 2020
Can confirm that this breaks
autogluon<=0.0.8withimport autogluonFix ImportError for scikit-learn >= 0.23
Innixma commentedon May 13, 2020
Issue on scikit-learn: scikit-learn/scikit-learn#17213
rth commentedon May 13, 2020
A temporary workaround for people experiencing this would be to monkeypatch the missing import (assuming numpy >=1.13.3),
A proper fix will be included in scikit-learn 0.23.1 (or if scikit-optimize makes a release with a fix from #904 before).
magic-lantern commentedon May 19, 2020
I am using skopt 0.7.4 and scikit-learn 0.23.1 and looks like 0.23.1 introduced some new errors.
Here's some example code taken straight from the website at https://scikit-optimize.github.io/stable/auto_examples/sklearn-gridsearchcv-replacement.html#minimal-example:
When I run this example, I get the following output:
If I downgrade scikit-learn back to 0.23.0 and do the monkey patch as described above, everything works ok.
prevent ImportError due to scikit-optimize and sklearn incompatibility
holgern commentedon May 20, 2020
There are also changes in Gaussian processes regression in sklearn 0.23 which needs to be migrated:
scikit-learn/scikit-learn#15782
GuillemGSubies commentedon Jun 5, 2020
Any updates on this? Can I help in any way?
xmatthias commentedon Jun 5, 2020
scikit-learn==0.23.1 does solve this for now.
they did properly deprecate the failing option now instead of simply removing:
source: scikit-learn/scikit-learn#17199
GuillemGSubies commentedon Jun 5, 2020
But the error
TypeError: object.__init__() takes exactly one argument (the instance to initialize)Is not solved with that, is it?xmatthias commentedon Jun 5, 2020
but that's not what this issue is about originally, that was just attached to this issue.
magic-lantern commentedon Jun 5, 2020
I added the information about
TypeError: object.__init__() takes exactly one argumentas it is part of scikit-optimize not being compatible with the most recent scikit-learn. Additionally some comments above said that the newest scikit-learn should remove the need for monkey patching. If it is preferred I can open a new issue (if the issue still exists).amueller commentedon Jun 15, 2020
I think this is actually part of the original issue as it was meant to be a fix, but I think there's an issue with the fix. If you want to look into it, I think we should fix it in sklearn.
ZhaoJunLee commentedon Jul 3, 2020
Instead of
from skopt import BayesSearchCV
try,
from skopt.searchcv import BayesSearchCV
this works well for me.
epx-dan commentedon Jul 6, 2020
I am using scikit-survival for building CoxPH survival model and BayesSearchCV for tunning, however, I have error
TypeError: object.__init__() takes no parameterswhen I try to runBayesSearchCV(estimator=CoxPHSurvivalAnalysis(), search_spaces=params_coxph, cv=10, n_jobs=-1).fit(X_train, y_train). How to solve this?scikit-learn==0.23.1
scikit-optimize==0.7.4
scikit-survival==0.13.0
holgern commentedon Sep 4, 2020
Version incompatibility has been fixed in #943 and #939 and in release 0.8.1