(y_true, y_pred, class_hierarchy, root=ROOT)
return true_positives / all_positives
Calculate the micro-averaged hierarchical recall ("hR") metric based on
    given set of true class labels and predicated class labels, and the
    class hierarchy graph.

    Note that the format expected here for `y_true` and `y_pred` is a
    binary multi-label matrix format, e.g. as can be generated by scikit-learn's
    MultiLabelBinarizer.

    For motivation and definition details, see:

        Functional Annotation of Genes Using Hierarchical Text
        Categorization, Kiritchenko et al 2008

        http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.68.5824&rep=rep1&type=pdf

    Parameters
    ----------
    y_true : array-like, shape = [n_samples, n_classes].
        Ground truth multi-class targets.

    y_pred : array-like, shape = [n_samples, n_classes].
        Predicted multi-class targets.

    class_hierarchy : the class hierarchy graph, given as a `networkx.DiGraph` instance.
        Node ids must be integer and correspond to the indices into the y_true / y_pred matrices.

    Returns
    -------
    hR : float
        The computed (micro-averaged) hierarchical recall score.
Calculate the micro-averaged hierarchical recall ("hR") metric based on
    given set of true class labels and predicated class labels, and the
    class hierarchy graph.
Calculate the micro - averaged hierarchical recall ( hR ) metric based on given set of true class labels and predicated class labels and the class hierarchy graph .
def h_recall_score(y_true, y_pred, class_hierarchy, root=ROOT):
    """
    Calculate the micro-averaged hierarchical recall ("hR") metric based on
    given set of true class labels and predicated class labels, and the
    class hierarchy graph.

    Note that the format expected here for `y_true` and `y_pred` is a
    binary multi-label matrix format, e.g. as can be generated by scikit-learn's
    MultiLabelBinarizer.

    For motivation and definition details, see:

        Functional Annotation of Genes Using Hierarchical Text
        Categorization, Kiritchenko et al 2008

        http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.68.5824&rep=rep1&type=pdf

    Parameters
    ----------
    y_true : array-like, shape = [n_samples, n_classes].
        Ground truth multi-class targets.

    y_pred : array-like, shape = [n_samples, n_classes].
        Predicted multi-class targets.

    class_hierarchy : the class hierarchy graph, given as a `networkx.DiGraph` instance.
        Node ids must be integer and correspond to the indices into the y_true / y_pred matrices.

    Returns
    -------
    hR : float
        The computed (micro-averaged) hierarchical recall score.

    """
    y_true_ = fill_ancestors(y_true, graph=class_hierarchy, root=root)
    y_pred_ = fill_ancestors(y_pred, graph=class_hierarchy, root=root)

    ix = np.where((y_true_ != 0) & (y_pred_ != 0))

    true_positives = len(ix[0])
    all_positives = np.count_nonzero(y_true_)

    return true_positives / all_positives
def h_recall_score ( y_true , y_pred , class_hierarchy , root = ROOT ) : y_true_ = fill_ancestors ( y_true , graph = class_hierarchy , root = root ) y_pred_ = fill_ancestors ( y_pred , graph = class_hierarchy , root = root ) ix = np . where ( ( y_true_ != 0 ) & ( y_pred_ != 0 ) ) true_positives = len ( ix [ 0 ] ) all_positives = np . count_nonzero ( y_true_ ) return true_positives / all_positives