chainer.functions.classification_summary(y, t, label_num=None, beta=1.0, ignore_label=-1)[source]

Calculates Precision, Recall, F beta Score, and support.

This function calculates the following quantities for each class.

  • Precision: \(\frac{\mathrm{tp}}{\mathrm{tp} + \mathrm{fp}}\)
  • Recall: \(\frac{\mathrm{tp}}{\mathrm{tp} + \mathrm{fn}}\)
  • F beta Score: The weighted harmonic average of Precision and Recall.
  • Support: The number of instances of each ground truth label.

Here, tp, fp, tn, and fn stand for the number of true positives, false positives, true negatives, and false negatives, respectively.

label_num specifies the number of classes, that is, each value in t must be an integer in the range of [0, label_num). If label_num is None, this function regards label_num as a maximum of in t plus one.

ignore_label determines which instances should be ignored. Specifically, instances with the given label are not taken into account for calculating the above quantities. By default, it is set to -1 so that all instances are taken into consideration, as labels are supposed to be non-negative integers. Setting ignore_label to a non-negative integer less than label_num is illegal and yields undefined behavior. In the current implementation, it arises RuntimeWarning and ignore_label-th entries in output arrays do not contain correct quantities.

  • y (Variable or N-dimensional array) – Variable holding a vector of scores.
  • t (Variable or N-dimensional array) – Variable holding a vector of ground truth labels.
  • label_num (int) – The number of classes.
  • beta (float) – The parameter which determines the weight of precision in the F-beta score.
  • ignore_label (int) – Instances with this label are ignored.

4-tuple of ~chainer.Variable of size (label_num,). Each element represents precision, recall, F beta score, and support of this minibatch.