In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

Identification evaluation metrics


In [2]:
from pyannote.core import Annotation, Segment

In [3]:
reference = Annotation()
reference[Segment(0, 10)] = 'A'
reference[Segment(12, 20)] = 'B'
reference[Segment(24, 27)] = 'A'
reference[Segment(30, 40)] = 'C'
reference


Out[3]:

In [4]:
hypothesis = Annotation()
hypothesis[Segment(2, 13)] = 'A'
hypothesis[Segment(13, 14)] = 'D'
hypothesis[Segment(14, 20)] = 'B'
hypothesis[Segment(22, 38)] = 'C'
hypothesis[Segment(38, 40)] = 'D'
hypothesis


Out[4]:

Identification error rate


In [5]:
from pyannote.metrics.identification import IdentificationErrorRate
identificationErrorRate = IdentificationErrorRate()
print("IER = {0:.3f}".format(identificationErrorRate(reference, hypothesis, uem=Segment(0, 40))))


IER = 0.516

Confusion matrix


In [6]:
imshow(reference * hypothesis, interpolation='nearest'); colorbar();


Precision and coverage


In [7]:
from pyannote.metrics.identification import IdentificationPrecision
precision = IdentificationPrecision()
print("Precision = {0:.3f}".format(precision(reference, hypothesis, uem=Segment(0, 40))))


Precision = 0.611

In [8]:
from pyannote.metrics.identification import IdentificationRecall
recall = IdentificationRecall()
print("Recall = {0:.3f}".format(recall(reference, hypothesis, uem=Segment(0, 40))))


Recall = 0.710