Annotate the tree by mapping the leaf target distributions to
some annotation for the leaves, then bubbling the annotations up
the tree using the Semigroup
for the annotation type.
For each leaf, this may convert the leaf to a SplitNode whose children
have the target distribution returned by calling fn
with the leaf's
index.
For each leaf, this may convert the leaf to a SplitNode whose children
have the target distribution returned by calling fn
with the leaf's
index. If fn
returns an empty Seq
, then the leaf is left as-is.
Returns the leaf with index leafIndex
that is a descendant of
start
by performing a DFS starting with start
.
Returns the leaf with index leafIndex
by performing a DFS.
Re-annotate the leaves of this tree using f
to transform the
annotations.
Re-annotate the leaves of this tree using f
to transform the
annotations. This will then bubble the annotations up the tree
using the Semigroup
for A1
. If f
is a semigroup
homomorphism, then this (semantically) just transforms the
annotation at each node using f
.
Maps the feature keys used to split the Tree
using f
.
Maps the Predicates in the Tree
using f
.
Maps the Predicates in the Tree
using f
. Note, this will
only produce a valid Tree
if f
preserves the ordering (ie if
a.compare(b) == f(a).compare(f(b))
).
Prune a tree to minimize validation error.
Prune a tree to minimize validation error.
Recursively replaces each split with a leaf when it would have a lower error than the sum of the child leaves errors.
A Map from leaf index to validation data.
to create predictions from target distributions.
to calculate an error statistic given observations (validation) and predictions (training).
The new, pruned tree.
Test conditions and optionally replace parent with a new leaf that combines children.
Test conditions and optionally replace parent with a new leaf that combines children.
Also merges validation data for any combined leaves. This relies on a hack that assumes no leaves have negative indices to start out.
Prune a tree to minimize validation error, starting from given root node.
Prune a tree to minimize validation error, starting from given root node.
This method recursively traverses the tree from the root, branching on splits, until it finds leaves, then goes back down the tree combining leaves when such a combination would reduce validation error.
Map from leaf index to validation data.
The root node of the tree.
A node at the root of the new, pruned tree.
Renumber all leaves in the tree.
Renumber all leaves in the tree.
A new tree with leaves renumbered.
For each LeafNode in this tree, this will replace it with the node
returned from fn
(called with the leaf node's index), if it returns
Some
node.
For each LeafNode in this tree, this will replace it with the node
returned from fn
(called with the leaf node's index), if it returns
Some
node. Otherwise, if fn
returns None
, then the leaf node is
left as-is.