Implementation of a top-down procedure to correct the scores of the hierarchy according to the
constraints that the score of a node cannot be greater than a score of its parents.
Usage
htd(S, g, root = "00")
Arguments
S
a named flat scores matrix with examples on rows and classes on columns.
g
a graph of class graphNEL. It represents the hierarchy of the classes.
root
name of the class that it is the top-level (root) of the hierarchy (def:00).
Value
a matrix with the scores of the classes corrected according to the HTD-DAG algorithm.
Details
The HTD-DAG algorithm modifies the flat scores according to the hierarchy of a DAG through a unique run across
the nodes of the graph. For a given example \(x \in X\), the flat predictions \(f(x) = \hat{y}\) are hierarchically corrected to
\(\bar{y}\), by per-level visiting the nodes of the DAG from top to bottom according to the following simple rule:
$$
\bar{y}_i := \left\{
\begin{array}{lll}
\hat{y}_i & {\rm if} \quad i \in root(G) \\
\min_{j \in par(i)} \bar{y}_j & {\rm if} \quad \min_{j \in par(i)} \bar{y}_j < \hat{y}_i \\
\hat{y}_i & {\rm otherwise}
\end{array}
\right.
$$
The node levels correspond to their maximum path length from the root.