Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save output graph of "dtreeviz.trees" dtreeviz on local HHD

Following is my code:

from sklearn import tree
from dtreeviz.trees import dtreeviz # will be used for tree visualization
from matplotlib import pyplot as plt
import graphviz

ax2 = dtreeviz(
 RFC1.estimators_[0],
 X_train1, y_train1, target_name='Mask',
 scale=1.1, class_names=['0','1'])
ax2

As I am working on jupyter notebook so I can see the graph as soon as I run ax2. I want to save this output to on my local system in PNG format BUT I can find a way to do this!

like image 650
Karar Shah Avatar asked Oct 17 '25 17:10

Karar Shah


1 Answers

Now its works different

Here is tutorial

It looks like:

import dtreeviz
viz_model = dtreeviz.model(clf,
                       X_train=X, y_train=y,
                       feature_names=iris.feature_names,
                       target_name='iris',
                       class_names=iris.target_names)

v = viz_model.view()     # render as SVG into internal object 
v.show()                 # pop up window
v.save("/tmp/iris.svg")  # optionally save as svg
like image 139
WhiteLedAnn Avatar answered Oct 20 '25 08:10

WhiteLedAnn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!