Skip to contents

Extracts class names from the outcome tibble (factor levels) and builds the ancestor matrix only for classes that actually appear in the data.

Usage

build_ancestor_matrix_from_outcomes(x, outcomes, device = "cpu")

Arguments

x

A data.tree::Node object.

outcomes

A tibble with factor columns (one per hierarchy level), as returned by hardhat::mold()$outcomes.

device

Torch device ("cpu" or "cuda").

Value

A torch_tensor of shape (1, n_classes, n_classes).