我在绘制 skopt 优化的学习曲线时遇到问题。这是我尝试过的:
from skopt.space import Real, Integer, Categorical
from skopt.utils import use_named_args
from skopt import BayesSearchCV
from skopt.plots import plot_convergence
rf = RandomForestRegressor(random_state =7, n_jobs=4)
def RunSKOpt(X_train, y_train):
hyper_parameters = {"n_estimators": (5, 500),
"max_depth": Categorical([3, None]),
"min_samples_split": (2, 10),
"min_samples_leaf": (1, 10)
}
search = BayesSearchCV(rf,
hyper_parameters,
n_iter = 40,
n_jobs = 4,
cv = 10,
verbose = 1,
return_train_score = False
)
return search
search = RunSKOpt(X_train, y_train)
search.fit(X_train, y_train)
plot_convergence(search)
情节是空的。请告诉我我做错了什么。
查尔斯
最佳答案
直接来自此 Github 问题线程:https://github.com/scikit-optimize/scikit-optimize/issues/751
BayesSearchCV was not intended for convergence plotting. You could however use the cv_results_ property of the *SearchCV, convert it to pandas (should be just creating dataframe out of the cv_results_ property) and then visualizing estimator performances for different iterations. The property is similar to those of GridSearchCV:
这是一个这样做的例子:
关于python - 如何从 skopt/BayesSearchCV 搜索中绘制学习曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55014090/