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{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
, andfn
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 int
must be an integer in the range of[0, label_num)
. Iflabel_num
isNone
, this function regardslabel_num
as a maximum of int
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. Settingignore_label
to a non-negative integer less thanlabel_num
is illegal and yields undefined behavior. In the current implementation, it arisesRuntimeWarning
andignore_label
-th entries in output arrays do not contain correct quantities.- Parameters
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.
- Returns
4-tuple of ~chainer.Variable of size
(label_num,)
. Each element represents precision, recall, F beta score, and support of this minibatch.