event_error_rate()

audmetric.event_error_rate(truth, prediction)[source]

Event error rate based on edit distance.

The event error rate is computed by aggregating the mean edit distances of each (truth, prediction)-pair and averaging the aggregated score by the number of pairs.

The mean edit distance of each (truth, prediction)-pair is computed as an average of the edit distance over the length of the longer sequence of the corresponding pair. By normalizing over the longer sequence the normalized distance is bound to [0, 1].

Parameters
  • truth (Union[str, Sequence[Union[str, Sequence[int]]]]) – ground truth classes

  • prediction (Union[str, Sequence[Union[str, Sequence[int]]]]) – predicted classes

Return type

float

Returns

event error rate

Raises

ValueError – if truth and prediction differ in length

Examples

>>> event_error_rate([[0, 1]], [[0]])
0.5
>>> event_error_rate([[0, 1], [2]], [[0], [2]])
0.25
>>> event_error_rate(["lorem"], ["lorm"])
0.2
>>> event_error_rate(["lorem", "ipsum"], ["lorm", "ipsum"])
0.1