python - 如何从 skopt/BayesSearchCV 搜索中绘制学习曲线

标签 python optimization scikit-learn

我在绘制 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:

这是一个这样做的例子:

enter image description here

关于python - 如何从 skopt/BayesSearchCV 搜索中绘制学习曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55014090/

相关文章:

python - 在 scikit-learn 管道中使用 gensim word2vec

python - 评估 scikit learn 中 SGD 分类器的收敛性

python - 向顶部/向下射击器添加滚动功能

python - 如何将文本文件读入字符串变量并去除换行符?

MySQL 多字段索引

language-agnostic - 为什么整个程序优化现在不流行了?

python - 如何将枚举传递给 ParameterGrid?

Python Timedelta 算术与 noleap 日历

python (pandas) - 连接列表时出现 TypeError : must be str, 未列出

javascript - 我怎样才能正确使用 jQuery 来修复这个 fencepost 案例?