confusion_matrix()¶
- audmetric.confusion_matrix(truth, prediction, labels=None, *, normalize=False)[source]¶
Confusion matrix.
- Parameters
truth (
Sequence
[Any
]) – ground truth values/classesprediction (
Sequence
[Any
]) – predicted values/classeslabels (
Optional
[Sequence
[Any
]]) – included labels in preferred ordering. If no labels are supplied, they will be inferred from and ordered alphabetically.normalize (
bool
) – normalize confusion matrix over the rows
- Return type
List
[List
[Union
[int
,float
]]]- Returns
confusion matrix
- Raises
ValueError – if
truth
andprediction
differ in length
Examples
>>> truth = [0, 1, 2] >>> prediction = [0, 2, 0] >>> confusion_matrix(truth, prediction) [[1, 0, 0], [0, 0, 1], [1, 0, 0]]