简体   繁体   中英

How to show catboost plot in google colab?

I was modelling boosting classifier using catboost module in google colaboratory. I followed the 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)

But this does not show any plot in Google Colab notebook.

Here is my code for 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 just prints <catboost.core.CatBoostClassifier at 0x7fc7a846d898> instead of showing the plot as shown in official webpage of catboost.

Catboost's plotting option does not work in Google Colab or Jupiter Lab yet. For now, the 'solution' is to run your code in a regular jupyter notebook instead.

There have been several discussions about this on Github, and catboost team members have acknowledged the issue. The real solution seems to be that they need to produce a special extension to enable plotting in Google Colab or Jupiter Lab. Unfortunately they stated in Oct. 2019 that "We are not working on that, we would very much appreciate any help!" https://github.com/catboost/catboost/issues/262

(see also: https://github.com/catboost/catboost/issues/1092 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM