Loading...

vastorbit.machine_learning.memmodel.cluster.BisectingKMeans.to_graphviz

BisectingKMeans.to_graphviz(round_score: int = 2, percent: bool = False, vertical: bool = True, node_style: dict | None = None, edge_style: dict | None = None, leaf_style: dict | None = None) str

Returns the code for a Graphviz tree.

Parameters:
  • round_score (int, optional) – The number of decimals to round the node’s score to 0 rounds to an integer.

  • percent (bool, optional) – If set to True, the scores are returned as a percent.

  • vertical (bool, optional) – If set to True, the function generates a vertical tree.

  • node_style (dict, optional) – Dictionary of options to customize each node of the tree. For a list of options, see the: Graphviz API .

  • edge_style (dict, optional) – Dictionary of options to customize each arrow of the tree. For a list of options, see the: Graphviz API .

  • leaf_style (dict, optional) – Dictionary of options to customize each leaf of the tree. For a list of options, see the: Graphviz API .

Returns:

Graphviz code.

Return type:

str

Examples

Import the required module.

from vastorbit.machine_learning.memmodel.cluster import BisectingKMeans

We will use the following attributes:

clusters = [
    [0.5, 0.6],
    [1, 2],
    [100, 200],
    [10, 700],
    [-100, -200],
]
children_left = [1, 3, None, None, None]
children_right = [2, 4, None, None, None]

Let’s create a model.

model_bkm = BisectingKMeans(clusters, children_left, children_right)

Get the model Graphviz representation.

model_bkm.to_graphviz()

Note

Refer to BisectingKMeans for more information about the different methods and usages.