Learn R Programming

HEMDAG (version 2.6.1)

hierarchical.checkers: Hierarchical constraints checker

Description

Check if the true path rule is violated or not. In other words this function checks if the score of a parent or an ancestor node is always larger or equal than that of its children or descendants nodes.

Usage

check.hierarchy.single.sample(y.hier, g, root = "00")

check.hierarchy(S.hier, g, root = "00")

Arguments

y.hier

vector of scores relative to a single example. This must be a named numeric vector.

g

a graph of class graphNEL. It represents the hierarchy of the classes.

root

name of the class that is on the top-level of the hierarchy (def. root="00").

S.hier

the matrix with the scores of the classes corrected in according to hierarchy. This must be a named matrix: rows are examples and columns are classes.

Value

return a list of 3 elements:

  • Status:

    • OK if none hierarchical constraints have bee broken;

    • NOTOK if there is at least one hierarchical constraints broken;

  • hierarchy_constraints_broken:

    • TRUE: example did not respect the hierarchical constraints;

    • FALSE: example broke the hierarchical constraints;

  • hierarchy_constraints_satisfied: how many terms satisfied the hierarchical constraint;

Examples

Run this code
# NOT RUN {
data(graph);
data(scores);
root <- root.node(g);
S.hier <- htd(S,g,root);
S.hier.single.example <- S.hier[sample(ncol(S.hier),1),];
check.hierarchy.single.sample(S.hier.single.example, g, root=root);
check.hierarchy(S.hier, g, root);
# }

Run the code above in your browser using DataLab