Canonical terminal endpoint map for a fitted CTA tree
cta_endpoint_table.RdReturns one row per terminal leaf (endpoint) of a cta_tree. All
values are read directly from stored node fields; no refitting or prediction
is performed. This is the canonical endpoint map for reporting, translation,
ORT, and staged workflows.
Leaf class counts are stored on every terminal node at fit time
(class_counts_raw, class_counts_weighted). target_n
and target_prop are derived from the stored counts.
ESS, WESS, p, LOO status, LOO ESS/WESSL, and LOOp are canonical split-node
report metrics (see cta_node_table). Terminal endpoints are
connected to those metrics through their parent split-node lineage. The
parent_split_* columns expose the immediate parent split's canonical
metrics for auditability. They are not recomputed ESS at the leaf.
Arguments
- tree
A
cta_treefromoda_cta_fit.- target_class
Integer class label to use as the target (positive) class for
target_nandtarget_prop. WhenNULL(default), the function auto-detects: for binary trees with classes0and1, class1is used; otherwisetarget_nandtarget_propareNA.
Value
A data.frame with one row per terminal leaf and columns:
endpoint_idInteger sequential endpoint index 1..n.
leaf_node_idInteger tree node identifier for this leaf.
terminal_markerCharacter
"*"on every row.terminalLogical
TRUEon every row.depthInteger depth from root (root = 1).
parent_split_node_idInteger parent split node identifier.
pathCharacter; AND-joined branch labels from root to this leaf (e.g.
"V14<=0.5 AND V15>0.5").nInteger raw observation count at this endpoint.
class_counts_rawList column; each element is a named integer vector of raw per-class counts, or
NULL.class_counts_weightedList column; each element is a named numeric vector of weighted per-class counts, or
NULL.predicted_classInteger class label assigned to this endpoint (stored leaf majority class).
target_nInteger count of
target_classobservations at this endpoint (NAwhen not resolvable).target_propNumeric proportion
target_n / n(NAwhen not resolvable).parent_split_attributeAttribute name of the parent split.
parent_split_essESS of the parent split node.
parent_split_wessWESS of the parent split node.
parent_split_loo_statusLOO status of the parent split node.
parent_split_loo_essLOO ESS/WESSL of the parent split node.
parent_split_p_mcMC p-value of the parent split node.
For a no-tree fit the returned data frame has zero rows but the correct column structure and types.
Examples
data(mtcars)
X <- mtcars[, c("cyl", "disp", "hp", "wt")]
y <- as.integer(mtcars$am)
tree <- oda_cta_fit(X, y, mindenom = 5L, mc_iter = 500L, mc_seed = 42L)
cta_endpoint_table(tree)
#> endpoint_id leaf_node_id terminal_marker terminal depth parent_split_node_id
#> 1 1 2 * TRUE 2 1
#> 2 2 3 * TRUE 2 1
#> path n predicted_class target_n target_prop parent_split_attribute
#> 1 wt>3.18 14 1 12 0.85714286 wt
#> 2 wt<=3.18 18 0 1 0.05555556 wt
#> parent_split_ess parent_split_wess parent_split_loo_status
#> 1 81.78138 81.78138 OFF
#> 2 81.78138 81.78138 OFF
#> parent_split_loo_ess parent_split_p_mc class_counts_raw class_counts_weighted
#> 1 NA 0 2, 12 2, 12
#> 2 NA 0 17, 1 17, 1