skactiveml.utils.ext_confusion_matrix#
- skactiveml.utils.ext_confusion_matrix(y_true, y_pred, classes=None, missing_label=nan, normalize=None)[source]#
Compute confusion matrix [1] to evaluate the accuracy of a classification.
This is an extension of the sklearn.metric.confusion_matrix [2] function by allowing missing labels and labels predicted by multiple annotators.
By definition a confusion matrix \(C\) is such that \(C_{i, j}\) is equal to the number of observations known to be in group \(i\) and predicted to be in group \(j\).
Thus, in binary classification, the count of true negatives is \(C_{0,0}\), false negatives is \(C_{1,0}\), true positives is \(C_{1,1}\) and false positives is \(C_{0,1}\).
- Parameters
- y_truearray-like of shape (n_samples)
Array of true labels. Is not allowed to contain any missing labels.
- y_predarray-like of shape (n_samples) or (n_samples, n_annotators)
Estimated targets as returned by multiple annotators.
- classesarray-like of shape (n_classes,), default=None
List of class labels to index the matrix. This may be used to reorder or select a subset of labels. If None is given, those that appear at least once in y_true or y_pred are used in sorted order.
- missing_labelscalar or string or np.nan or None, default=np.nan
Value to represent a missing label.
- normalize‘true’ or ‘pred’ or ‘all’, default=None
Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, confusion matrix will not be normalized.
- Returns
- conf_matricesnumpy.ndarray, shape (n_annotators, n_classes, n_classes)
Confusion matrix whose i-th row and j-th column entry indicates the number of samples with true label being i-th class and predicted label being j-th class.
References
- 1
Wikipedia entry for the Confusion matrix (Wikipedia and other references may use a different convention for axes)
- 2