scikit-learnvisualizationgoogle-colaboratorydecision-treedtreeviz

Visualise a decision tree in Colaboratory


What is the best way to visualise a decision tree using Google Colab? The visualisations from 'dtreeviz' (e.g.Github) are really neat, but when running something like

!pip install dtreeviz

and

from sklearn.datasets import *
from sklearn import tree
from dtreeviz.trees import *

followed by

classifier = tree.DecisionTreeClassifier(max_depth=4)
cancer = load_breast_cancer()
classifier.fit(cancer.data, cancer.target)
viz = dtreeviz(classifier,
              cancer.data,
              cancer.target,
              target_name='cancer',
              feature_names=cancer.feature_names, 
              class_names=["malignant", "benign"],
              fancy=False )  

viz.view()

I get

ExecutableNotFound: failed to execute ['dot', '-Tsvg', '-o', '/tmp/DTreeViz_62.svg', '/tmp/DTreeViz_62'], make sure the Graphviz executables are on your systems' PATH

Which could have something to do which Colab running via my g-drive?

Any help appreciated!


Solution

  • Short answer

    Longer answer