Skip to contents

Returns 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.

Usage

cta_endpoint_table(tree, target_class = NULL)

Arguments

tree

A cta_tree from oda_cta_fit.

target_class

Integer class label to use as the target (positive) class for target_n and target_prop. When NULL (default), the function auto-detects: for binary trees with classes 0 and 1, class 1 is used; otherwise target_n and target_prop are NA.

Value

A data.frame with one row per terminal leaf and columns:

endpoint_id

Integer sequential endpoint index 1..n.

leaf_node_id

Integer tree node identifier for this leaf.

terminal_marker

Character "*" on every row.

terminal

Logical TRUE on every row.

depth

Integer depth from root (root = 1).

parent_split_node_id

Integer parent split node identifier.

path

Character; AND-joined branch labels from root to this leaf (e.g. "V14<=0.5 AND V15>0.5").

n

Integer raw observation count at this endpoint.

class_counts_raw

List column; each element is a named integer vector of raw per-class counts, or NULL.

class_counts_weighted

List column; each element is a named numeric vector of weighted per-class counts, or NULL.

predicted_class

Integer class label assigned to this endpoint (stored leaf majority class).

target_n

Integer count of target_class observations at this endpoint (NA when not resolvable).

target_prop

Numeric proportion target_n / n (NA when not resolvable).

parent_split_attribute

Attribute name of the parent split.

parent_split_ess

ESS of the parent split node.

parent_split_wess

WESS of the parent split node.

parent_split_loo_status

LOO status of the parent split node.

parent_split_loo_ess

LOO ESS/WESSL of the parent split node.

parent_split_p_mc

MC 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