chainer.functions.classification_summary¶
-
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{tn}}\)
F beta Score: The weighted harmonic average of Precision and Recall.
Support: The number of instances of each ground truth label.
Here,
tp,fp, andtnstand for the number of true positives, false positives, and true negative, respectively.label_numspecifies the number of classes, that is, each value intmust be an integer in the range of[0, label_num). Iflabel_numisNone, this function regardslabel_numas a maximum of intplus one.ignore_labeldetermines 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. Settingignore_labelto a non-negative integer less thanlabel_numis illegal and yields undefined behavior. In the current implementation, it arisesRuntimeWarningandignore_label-th entries in output arrays do not contain correct quantities.- Parameters
y (
Variableor N-dimensional array) – Variable holding a vector of scores.t (
Variableor 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.
- Returns
4-tuple of ~chainer.Variable of size
(label_num,). Each element represents precision, recall, F beta score, and support of this minibatch.