Model.to_graphviz¶
In [ ]:
Model.to_graphviz(tree_id: int = 0,
classes_color: list = [],
round_pred: int = 2,
percent: bool = False,
vertical: bool = True,
node_style: dict = {},
arrow_style: dict = {},
leaf_style: dict = {},)
Returns the code for a Graphviz tree.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
tree_id | int | ✓ | Unique tree identifier. It is an integer between 0 and n_estimators - 1 |
classes_color | list | ✓ | Colors that represent the different classes. |
round_pred | int | ✓ | The number of decimals to round the prediction to. 0 rounds to an integer. |
percent | bool | ✓ | If set to True, the probabilities are returned as a percent. |
vertical | bool | ✓ | If set to True, the function generates a vertical tree. |
node_style | dict | ✓ | Dictionary of options to customize each node of the tree. For a list of options, see the Graphviz API: https://graphviz.org/doc/info/attrs.html |
arrow_style | dict | ✓ | Dictionary of options to customize each arrow of the tree. For a list of options, see the Graphviz API: https://graphviz.org/doc/info/attrs.html |
leaf_style | dict | ✓ | Dictionary of options to customize each leaf of the tree. For a list of options, see the Graphviz API: https://graphviz.org/doc/info/attrs.html |
Example¶
In [19]:
from verticapy.learn.ensemble import RandomForestClassifier
model = RandomForestClassifier(name = "public.RF_iris",
n_estimators = 20,
max_features = "auto",
max_leaf_nodes = 32,
sample = 0.7,
max_depth = 3,
min_samples_leaf = 5,
min_info_gain = 0.0,
nbins = 32)
model.fit("public.iris",
["PetalLengthCm", "PetalWidthCm"],
"Species")
model.to_graphviz(tree_id = 3)
Out[19]:
