用 Yellowbrick 绘制 CatBoostClassifier 的学习曲线

Plot Learning Curve of CatBoostClassifier with Yellowbrick

我正在尝试绘制 CatBoostClassifier 的学习曲线。 当我将 CatBoostClassifier 从 yellowbrick 放入 LearningCurve 时会发生错误。 我认为这应该可行,因为 CatBoost 与 sklearn 兼容,而黄砖是 sklearn 的扩展。

代码片段:

kf = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=0)
sizes = np.linspace(0.2, 1.0, 10)
estimator = CatBoostClassifier(
    iterations=42, learning_rate=0.3, max_depth=10)

visualizer = LearningCurve(
    estimator, cv=kf, scoring='accuracy', train_sizes=sizes, n_jobs=-1
)

visualizer.fit(X, y)
visualizer.show()

错误:

... yellowbrick.exceptions.YellowbrickTypeError: Cannot detect the model name for non estimator: ''

有什么建议吗?

我可以为 XGBClassifier 绘制学习曲线,我认为它也应该适用于 CatBoostClassifier。 visualizer.show() 虽然不起作用。使用 visualizer.poof() 渲染绘图。

您可以使用第三方估算器的包装器,more details。我试过了,它奏效了。像这样:

from yellowbrick.classifier import ROCAUC
from yellowbrick.contrib.wrapper import wrap

catboost_model = CatBoostClassifier()
model = wrap(catboost_model)
visualizer = ROCAUC(model)
visualizer.fit(X_train, y_train)
visualizer.score(X_test, y_test)
visualizer.show()