memModel.to_graphviz¶
In [ ]:
memModel.to_graphviz(tree_id: int = 0,
feature_names: Union[list, np.ndarray] = [],
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, an integer in the range [0, n_estimators - 1]. |
feature_names | list / numpy.array | ✓ | List of the names of each feature. |
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 |
Returns¶
graphviz.Source : graphviz object.
Example¶
In [11]:
from verticapy.learn.memmodel import memModel
model = memModel("BinaryTreeClassifier", {"children_left": [1, 3, None, None, None],
"children_right": [2, 4, None, None, None],
"feature": [0, 1, None, None, None],
"threshold": ['female', 30, None, None, None],
"value": [None, None, [0.8, 0.1, 0.1], [0.1, 0.8, 0.1], [0.2, 0.2, 0.6]],
"classes": ['a', 'b', 'c',]})
model.to_graphviz()
Out[11]:
