Choreo.DecisionTree.Render.DOT (Choreo v0.7.0)

Copy Markdown View Source

DOT (Graphviz) rendering for Choreo.DecisionTree.

Produces tree-oriented visualisation:

  • Root — diamond with double border
  • Decisions — diamonds
  • Outcomes — rounded rectangles with class colour coding

Layout is top-down so decisions flow downward to outcomes. Edge labels show the branch condition.

Summary

Functions

Renders a decision tree to a DOT string.

Functions

to_dot(tree, opts \\ [])

@spec to_dot(
  Choreo.DecisionTree.t(),
  keyword()
) :: String.t()

Renders a decision tree to a DOT string.

Options

Examples

iex> tree = Choreo.DecisionTree.new()
iex> tree = tree
...>   |> Choreo.DecisionTree.set_root(:color, feature: "color")
...>   |> Choreo.DecisionTree.add_outcome(:stop, label: "Stop")
...>   |> Choreo.DecisionTree.add_outcome(:go, label: "Go")
...>   |> Choreo.DecisionTree.branch(:color, :stop, "red")
...>   |> Choreo.DecisionTree.branch(:color, :go, "green")
iex> dot = Choreo.DecisionTree.Render.DOT.to_dot(tree)
iex> String.contains?(dot, "digraph")
true
iex> String.contains?(dot, "red")
true
iex> String.contains?(dot, "green")
true