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

时间:2019-03-06 01:22:33

标签: 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)

情节是空的。请告诉我我在做错什么。

查尔斯

1 个答案:

答案 0 :(得分:0)

直接来自此Github问题线程:https://github.com/scikit-optimize/scikit-optimize/issues/751

  

BayesSearchCV不适用于收敛图。你可以   但是,请使用* SearchCV的cv_results_属性,将其转换为   熊猫(应该只是从cv_results_中创建数据框   属性),然后可视化不同估算器的效果   迭代。该属性类似于GridSearchCV的属性:

这是一个这样做的例子:

enter image description here