srlearn.plotting
.export_digraph¶
-
srlearn.plotting.
export_digraph
(booster, tree_index=0, out_file=None)[source]¶ Create a digraph representation of a tree.
Parameters: - booster : BaseBoostedRelationalModel
Model to create a tree from
- tree_index : int
Index of the tree to visualize
- out_file : str, pathlike, or None
Handle or name of the output file. If
None
, returns a string
Examples
This can be used in two ways: returning a string, or directly writing the result to a file.
from srlearn.rdn import BoostedRDNClassifier from srlearn import Background from srlearn.datasets import load_toy_cancer from srlearn.plotting import export_digraph train, _ = load_toy_cancer() bkg = Background( modes=train.modes, ) clf = BoostedRDNClassifier( background=bkg, target="cancer", ) clf.fit(train) print(export_digraph(clf, tree_index=0))