In [1]:
%pylab inline
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]:
In [5]:
from pyannote.metrics.identification import IdentificationErrorRate
identificationErrorRate = IdentificationErrorRate()
print("IER = {0:.3f}".format(identificationErrorRate(reference, hypothesis, uem=Segment(0, 40))))
In [6]:
imshow(reference * hypothesis, interpolation='nearest'); colorbar();
In [7]:
from pyannote.metrics.identification import IdentificationPrecision
precision = IdentificationPrecision()
print("Precision = {0:.3f}".format(precision(reference, hypothesis, uem=Segment(0, 40))))
In [8]:
from pyannote.metrics.identification import IdentificationRecall
recall = IdentificationRecall()
print("Recall = {0:.3f}".format(recall(reference, hypothesis, uem=Segment(0, 40))))