如何在Google Colab中显示Catboost图?

时间:2019-11-23 16:46:53

标签: python pandas google-colaboratory catboost

我正在使用Google colaboratory中的catboost模块对提升分类器进行建模。 我遵循了official example

from catboost import CatBoostClassifier, Pool

train_data = [[1, 3], [0, 4], [1, 7], [0, 3]]
train_labels = [1, 0, 1, 1]

model = CatBoostClassifier(learning_rate=0.03)

model.fit(train_data,
          train_labels,
          verbose=False,
          plot=True)

但这不会在Google Colab笔记本中显示任何情节。

这是我的Google colab代码:

import sys
ENV_COLAB = 'google.colab' in sys.modules

if ENV_COLAB:

    !pip install catboost
    !pip install ipywidgets
    !jupyter nbextension enable --py widgetsnbextension

    print('Environment: Google Colab')

from catboost import CatBoostClassifier, Pool

train_data = [[1, 3], [0, 4], [1, 7], [0, 3]]
train_labels = [1, 0, 1, 1]

model = CatBoostClassifier(learning_rate=0.03)

model.fit(train_data,
          train_labels,
          verbose=False,
          plot=True)

Google colab仅打印<catboost.core.CatBoostClassifier at 0x7fc7a846d898>,而不显示catboost官方网页中显示的图。

1 个答案:

答案 0 :(得分:3)

Catboost的绘图选项在Google Colab或Jupiter Lab中尚不起作用。目前,“解决方案”是在常规的jupyter笔记本中运行代码。

在Github上对此进行了多次讨论,catboost团队成员已经意识到了这个问题。真正的解决方案似乎是他们需要产生一个特殊的扩展名才能在Google Colab或Jupiter Lab中进行绘图。不幸的是,他们在2019年10月表示:“我们没有为此努力,我们将非常感谢您的帮助!” https://github.com/catboost/catboost/issues/262

(另请参见:https://github.com/catboost/catboost/issues/1092