htd {HEMDAG} | R Documentation |
HTD-DAG
Description
Implementation of the 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 |
root |
name of the class that it is the top-level of the hierarchy ( |
Details
The HTD-DAG
algorithm modifies the flat scores according to the hierarchy of a DAG G
through a unique run across
the nodes of the graph. For a given example 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.
Value
A matrix with the scores of the classes corrected according to the HTD-DAG
algorithm.
Examples
data(graph);
data(scores);
root <- root.node(g);
S.htd <- htd(S,g,root);