当我使用scikit-optimize
0.7.4 版本优化scikit-learn
0.23 模型时:
rf = BayesSearchCV(
RandomForestClassifier(
min_samples_leaf=0.01, oob_score=True
), {
'n_estimators': Integer(30, 200),
'max_depth': Integer(10, 150),
'min_samples_split': Real(0.05, 0.3),
}, n_iter=32
)
当我跑步时rf.fit
,它说,
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\space\space.py", line 764, in rvs
if sp_version < (0, 16):
TypeError: '<' not supported between instances of 'Version' and 'tuple'
但是当我简单地使用RandomForestClassifier
并安装它时,就不会发生错误。那么,如何避免这个问题呢?谢谢!
完整的回溯如下。
Traceback (most recent call last):
File "C:/Users/cloudy/PyCharmProjects/clixove/BasicML/classifier.py", line 106, in <module>
rf.fit(clf.data['X_train'], clf.data['Y_train'])
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\searchcv.py", line 678, in fit
optim_result = self._step(
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\searchcv.py", line 552, in _step
params = optimizer.ask(n_points=n_points)
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\optimizer\optimizer.py", line 360, in ask
x = opt.ask()
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\optimizer\optimizer.py", line 332, in ask
return self._ask()
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\optimizer\optimizer.py", line 398, in _ask
return self.space.rvs(random_state=self.rng)[0]
File "C:\Users\cloudy\PyCharmProjects\clixove\venv\lib\site-packages\skopt\space\space.py", line 764, in rvs
if sp_version < (0, 16):
TypeError: '<' not supported between instances of 'Version' and 'tuple'