accuracy()¶
- audmetric.accuracy(truth, prediction, labels=None)[source]¶
Classification accuracy.
- Parameters
truth (
Sequence
[Any
]) – ground truth values/classesprediction (
Sequence
[Any
]) – predicted values/classeslabels (
Optional
[Sequence
[Union
[str
,int
]]]) – included labels in preferred ordering. Sample is considered in computation if either prediction or ground truth (logical OR) is contained in labels. If no labels are supplied, they will be inferred from and ordered alphabetically.
- Return type
float
- Returns
accuracy of prediction
- Raises
ValueError – if
truth
andprediction
differ in length
Examples
>>> accuracy([0, 0], [0, 1]) 0.5