Repository navigation
Expand file tree
/
Copy pathevaluation.tex
More file actions
1541 lines (1316 loc) · 74.9 KB
/
Copy pathevaluation.tex
File metadata and controls
1541 lines (1316 loc) · 74.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapt[chap:eval]{Performance Evaluation of Language Analysers}
\markboth{Performance Evaluation of Language Analysers}{Performance Evaluation of Language Analysers}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GATE provides a variety of tools for automatic evaluation. The Annotation Diff
tool compares two annotation sets within a document. Corpus QA extends Annotation
Diff to an entire corpus. The Corpus Benchmark tool also provides
functionality for comparing annotation sets over an entire corpus. Additionally,
two plugins cover similar functionality; one implements inter-annotator
agreement, and the other, the balanced distance metric.
These tools are particularly useful not just as a final measure of performance,
but as a tool to aid system development by tracking progress and evaluating the
impact of changes as they are made. Applications include evaluating the success
of a machine learning or language engineering application by comparing its
results to a gold standard and also comparing annotations prepared by two
human annotators to each other to ensure that the annotations are reliable.
This chapter begins by introducing the concepts and metrics relevant, before
describing each of the tools in turn.
% The
%Annotation Diff tool enables automated performance measurement and
%visualisation of the results, while the corpus benchmark tool enables the
%tracking of a system's progress and regression testing.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\sect[sec:eval:metrics]{Metrics for Evaluation in Information Extraction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
When we evaluate the performance of a processing resource such as tokeniser, POS
tagger, or a whole application, we usually have a human-authored `gold standard'
against which to compare our software. However, it is not always easy or obvious
what this gold standard should be, as different people may have different
opinions about what is correct. Typically, we solve this problem by using more
than one human annotator, and comparing their annotations. We do this by
calculating inter-annotator agreement (IAA), also known as inter-rater reliability.
IAA can be used to assess how difficult a task is. This is based on the argument
that if two humans cannot come to agreement on some annotation, it is unlikely
that a computer could ever do the same annotation `correctly'. Thus, IAA can be
used to find the ceiling for computer performance.
There are many possible metrics for reporting IAA, such as Cohen's Kappa,
prevalence, and bias \cite{Eugenio04}. Kappa is the best metric for IAA when all
the annotators have identical exhaustive sets of questions on which they might
agree or disagree. In other words, it is a classification task. This could be a
task like `are these names male or female names'. However, sometimes there is
disagreement about the set of questions, e.g. when the annotators themselves
determine which text spans they ought to annotate, such as in named entity
extraction. That could be a task like `read over this text and mark up all
references to politics'. When annotators determine their own sets of questions,
it is appropriate to use precision, recall, and F-measure to report IAA.
Precision, recall and F-measure are also appropriate choices when assessing
performance of an automated application against a trusted gold standard.
In this section, we will first introduce some relevant terms, before outlining
Cohen's Kappa and similar measures, in Section~\ref{sec:eval:kappa}. We will then
introduce precision, recall and F-measure in Section~\ref{sec:eval:prf}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:benchmarktoolrelation]{Annotation Relations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Before introducing the metrics we will use in this \chapthing, we will first
outline the ways in which annotations can relate to each other. These ways of
comparing annotations to each other are used to determine the counts that then go
into calculating the metrics of interest. Consider a document with two annotation
sets upon it. These annotation sets might for example be prepared by two human
annotators, or alternatively, one set might be produced by an automated system
and the other might be a trusted gold standard. We wish to assess the extent to
which they agree. We begin by counting incidences of the following relations:
\begin{description}
\item[Coextensive] Two annotations are coextensive if they hit the same span of
text in a document. Basically, both their start and end offsets are equal.
\item[Overlaps] Two annotations overlap if they share a common span of text.
\item[Compatible] Two annotations are compatible if they are coextensive and if
the features of one (usually the ones from the key) are included in
the features of the other (usually the response).
\item[Partially Compatible] Two annotations are partially compatible if they
overlap and if the features of one (usually the ones from the key) are included in
the features of the other (response).
\item[Missing] This applies only to the key annotations. A key annotation is
missing if either it is not coextensive or overlapping, orif one or more
features are not included in the response annotation.
\item[Spurious] This applies only to the response annotations. A response
annotation is spurious if either it is not coextensive or overlapping, or if one or
more features from the key are not included in the response
annotation.
\end{description}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:kappa]{Cohen's Kappa}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The three commonly used IAA measures are {\em observed agreement}, {\em specific agreement},
and {\em Kappa ($\kappa$)} \cite{Hripcsak02}. Those measures can be
calculated from a contingency table, which lists the numbers of instances of
agreement and disagreement between two annotators on each category. To explain the
IAA measures, a general contingency table for two categories {\em cat1} and {\em cat2}
is shown in Table \ref{table:iaa-kappa:contingency}.
\begin{table}[hbt]
{\centering
\begin{tabular}{|l|cc|c|}
\hline
& Annotator-2 & & \\
\hline
Annotator-1 & cat1 & cat2 & marginal sum\\
\hline
cat1& a & b & a+b\\
cat2 & c & d & c+d\\
\hline
marginal sum & a+c & b+d &a+b+c+d\\
\hline
\end{tabular}\par}
\caption{Contingency table for two-category problem}
\label{table:iaa-kappa:contingency}
\end{table}
{\bf Observed agreement} is the portion of the instances on which the
annotators agree. For the two annotators and two categories as shown in
Table \ref{table:iaa-kappa:contingency}, it is defined as
\begin{equation}
A_{o} = \frac{a+d}{a+b+c+d}
\end{equation}
The extension of the above formula to more than two categories is
straightforward. The extension to more than two annotators is usually taken
as the mean of the pair-wise agreements \cite{Fleiss75}, which is the average agreement
across all possible pairs of annotators.
An alternative compares each annotator with the majority opinion of the others
\cite{Fleiss75}.
However, the observed agreement has two shortcomings. One is that a certain
amount of agreement is expected by chance. The Kappa measure is a chance-corrected
agreement. Another is that it sums up the agreement on all the categories, but
the agreements on each category may differ. Hence the category specific agreement
is needed.
{\bf Specific agreement} quantifies the degree of agreement for each of the categories
separately. For example, the specific agreement for the two categories list in
Table \ref{table:iaa-kappa:contingency} is the following, respectively,
\begin{equation}
A_{cat1} = \frac{2a}{2a+b+c}; \ \ \
A_{cat2} = \frac{2d}{b+c+2d}
\end{equation}
{\bf Kappa} is defined as the observed agreements $A_{o}$ minus the agreement
expected by chance $A_{e}$ and is normalized as a number between -1 and 1.
\begin{equation}
\kappa =\frac{A_{o}-A_{e}}{1-A_{e}}
\end{equation}
$\kappa=1$ means perfect agreements, $\kappa=0$ means the agreement is equal to
chance, $\kappa=-1$ means `perfect' disagreement.
There are two different ways of computing the chance agreement $A_{e}$ (for a
detailed explanations about it see \cite{Eugenio04}; however, a quick outline
will be given below). The Cohen's Kappa is based on the individual distribution
of each annotator, while the Siegel \& Castellan's Kappa is based on the
assumption that all the annotators have the same distribution. The former is more
informative than the latter and has been used widely.
Let us consider an example:
\begin{table}[hbt]
{\centering
\begin{tabular}{|l|cc|c|}
\hline
& Annotator-2 & & \\
\hline
Annotator-1 & cat1 & cat2 & marginal sum\\
\hline
cat1& 1 & 2 & 3\\
cat2 & 3 & 4 & 7\\
\hline
marginal sum & 4 & 6 &10\\
\hline
\end{tabular}\par}
\caption{Example contingency table for two-category problem}
\label{table:iaa-kappa:contingencyex}
\end{table}
{\bf Cohen's Kappa} requires that the expected agreement be calculated as
follows. Divide marginal sums by the total to get the portion of the instances
that each annotator allocates to each category. Multiply annotator's
proportions together to get the likelihood of chance agreement, then total
these figures. Table~\ref{table:iaa-kappa:cohens} gives a worked example.
\begin{table}[hbt]
{\centering
\begin{tabular}{|l|l|l|l|}
\hline
& Annotator-1 & Annotator 2 & Multiplied \\
\hline
cat1 & 3 / 10 = 0.3 & 4 / 10 = 0.4 & 0.12 \\
cat2 & 7 / 10 = 0.7 & 6 / 10 = 0.6 & 0.42 \\
\hline
Total & & & 0.54 \\
\hline
\end{tabular}\par}
\caption{Calculating Expected Agreement for Cohen's Kappa}
\label{table:iaa-kappa:cohens}
\end{table}
The formula can easily be extended to more than two categories.
{\bf Siegel \& Castellan's Kappa} is applicable for any number of annotators.
Siegel \& Castellan's Kappa for two annotators is also known as Scott's Pi (see
\cite{Lombard02}). It differs from Cohen's Kappa only in how the expected
agreement is calculated. Table~\ref{table:iaa-kappa:scotts} shows a worked
example. Annotator totals are added together and divided by the number of
decisions to form joint proportions. These are then squared and totalled.
\begin{table}[hbt]
{\centering
\begin{tabular}{|l|l|l|l|l|l|}
\hline
& Ann-1 & Ann-2 & Sum & Joint Prop &
JP-Squared \\
\hline
cat1 & 3 & 4 & 7 & 7/20 & 49/400=0.1225 \\
cat2 & 7 & 6 & 13 & 13/20 & 169/400=0.4225 \\
\hline
Total & & & & & 218/400 = 0.545 \\
\hline
\end{tabular}\par}
\caption{Calculating Expected Agreement for Siegel \& Castellan's Kappa
(Scott's Pi)}
\label{table:iaa-kappa:scotts}
\end{table}
The Kappa suffers from the prevalence problem which arises because imbalanced
distribution of categories in the data increases $A_{e}$. The prevalence problem
can be alleviated by reporting the positive and negative specified agreement on
each category besides the Kappa \cite{ Hripcsak02, Eugenio04}. In addition, the
so-called bias problem affects the Cohen's Kappa, but not S\&C's. The bias
problem arises as one annotator prefers one particular category more than another
annotator. \cite{Eugenio04} advised to compute the S\&C's Kappa and the specific
agreements along with the Cohen's Kappa in order to handle these problems.
Despite the problem mentioned above, the Cohen's Kappa remains a popular IAA measure.
Kappa can be used for more than two annotators based on pair-wise figures, e.g. the mean
of all the pair-wise Kappa as an overall Kappa measure. The Cohen's Kappa can also be
extended to the case of more than two annotators by using the following single
formula \cite{Davies82}
\begin{equation}
\kappa = 1-\frac{IJ^{2}-\sum_{i}\sum_{c}Y_{ic}^{2}}
{I(J(J-1)\sum_{c}(p_{c}(1-p_{c}))+ \sum_{c}\sum_{j}(p_{cj}-p_{c})^2)}
\end{equation}
Where $I$ and $J$ are the number of instances and annotators, respectively; $Y_{ic}$
is the number of annotators who assigns the category $c$ to the instance $I$; $p_{cj}$
is the probability of the annotator $j$ assigning category $c$; $p_{c}$ is the
probability of assigning category by all annotators (i.e. averaging $p_{cj}$
over all annotators).
The Krippendorff's alpha, another variant of Kappa, differs only slightly from
the S\&C's Kappa on nominal category problem (see \cite{Carletta96, Eugenio04}).
However, note that the Kappa (and the observed agreement) is not applicable to some
tasks. Named entity annotation is one such task
\cite{Hripcsak05}. In the named entity annotation task, annotators are given
some text and are asked to annotate some named entities (and possibly their
categories) in the text. Different annotators may annotate different instances
of the named entity. So, if one annotator annotates one named entity in the text but
another annotator does not annotate it, then that named entity is a non-entity
for the latter. However, generally the non-entity in the text is not a well-defined
term, e.g. we don't know how many words should be contained in the non-entity. On the
other hand, if we want to compute Kappa for named entity annotation, we need
the non-entities. This is why people don't compute Kappa for the named entity task.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:prf]{Precision, Recall, F-Measure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Much of the research in IE in the last decade has been connected with
the MUC competitions, and so it is unsurprising that the MUC
evaluation metrics of precision, recall and F-measure
\cite{Chinchor92} also tend to be used, along with slight
variations. These metrics have a very long-standing tradition in the
field of IR \cite{van79} (see also \cite{Man99,Fra92}).
\textbf{Precision} measures the number of correctly identified items
as a percentage of the number of items identified. In other words, it
measures how many of the items that the system identified were
actually correct, regardless of whether it also failed to retrieve
correct items. The higher the precision, the better the system is
at ensuring that what is identified is correct.
\textbf{Error rate} is the inverse of precision, and measures the
number of incorrectly identified items as a percentage of the items
identified. It is sometimes used as an alternative to precision.
\textbf{Recall} measures the number of correctly identified items as a
percentage of the total number of correct items. In other words, it
measures how many of the items that should have been identified
actually were identified, regardless of how many spurious
identifications were made. The higher the recall rate, the better the
system is at not missing correct items.
Clearly, there must be a tradeoff between precision and recall, for a
system can easily be made to achieve 100\% precision by identifying
nothing (and so making no mistakes in what it identifies), or 100\%
recall by identifying everything (and so not missing anything). The
\textbf{F-measure} \cite{van79} is often used in conjunction with
Precision and Recall, as a weighted average of the two.
\textbf{False positives} are a
useful metric when dealing with a wide variety of text types, because
it is not dependent on \textit{relative document richness} in the same way that
precision is. By this we mean the relative number of entities of each type
to be found in a set of documents.
When comparing different systems on the same document set, relative
document richness is unimportant, because it is equal for all
systems. When comparing a single system's performance on different
documents, however, it is much more crucial, because if a particular
document type has a significantly different number of any type of
entity, the results for that entity type can become skewed.
Compare the impact on precision of
one error where the total number of correct entities = 1, and one
error where the total = 100. Assuming the document length is the
same, then the false positive score for each text, on the other hand,
should be identical.
Common metrics for evaluation of IE systems are defined as follows:
\begin{equation}
Precision = \frac{Correct + 1/2 Partial}{Correct + Spurious + Partial}
\end{equation}
\begin{equation}
Recall = \frac{Correct + 1/2 Partial}{Correct + Missing + Partial}
\end{equation}
\begin{equation}
F-measure = \frac{(\beta^2 + 1) P * R}{(\beta^2P) + R}
\end{equation}
where $\beta$ reflects the weighting of P vs. R. If $\beta$ is set to 1, the
two are weighted equally. With $\beta$ set to 0.5, precision weights twice
as much as recall. And with $\beta$ set to 2, recall weights twice as much
as precision.
\begin{equation}
False Positive = \frac{Spurious}{c}
\end{equation}
where \textit{c} is some constant independent from document
richness, e.g. the number of tokens or sentences in the document.
Note that we consider annotations to be partially correct if the
entity type is correct and the spans are overlapping but not
identical. Partially correct responses are normally allocated a half
weight.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:macromicro]{Macro and Micro Averaging}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Where precision, recall and f-measure are calculated over a corpus, there are
options in terms of how document statistics are combined.
\begin{itemize}
\item Micro averaging essentially treats the corpus as one large document.
Correct, spurious and missing counts span the entire corpus, and precision,
recall and f-measure are calculated accordingly.
\item Macro averaging calculates precision, recall and f-measure on a per
document basis, and then averages the results.
\end{itemize}
The method of choice depends on the priorities of the case in question. Macro
averaging tends to increase the importance of shorter documents.
It is also possible to calculate a macro average across annotation types; that
is to say, precision, recall and f-measure are calculated separately for each
annotation type and the results then averaged.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\sect[sec:eval:annotationdiff]{The Annotation Diff Tool}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
The Annotation Diff tool enables two sets of annotations in one or two
documents to be compared, in order either to compare a system-annotated
text with a reference (hand-annotated) text, or to compare the output
of two different versions of the system (or two different
systems). For each annotation type, figures are generated for
precision, recall, F-measure.
Each of these can be calculated according to 3 different
criteria - strict, lenient and average. The reason for this is to deal
with partially correct responses in different ways.
\begin{itemize}
\item The Strict measure considers all partially correct
responses as incorrect (spurious).
\item The Lenient measure considers all partially correct
responses as correct.
\item The Average measure allocates a half weight to
partially correct responses (i.e. it takes the average of strict
and lenient).
\end{itemize}
It can be accessed both from GATE Developer and from GATE Embedded.
Annotation Diff compares sets of annotations with the same type. When
performing the comparison, the annotation offsets and their features will be
taken into consideration. and after that, the comparison process is
triggered.
All annotations from the key set are compared with the ones from
the response set, and those found to have the same start and end
offsets are displayed on the same line in the table. Then, the
Annotation Diff evaluates if the features of each annotation from
the response set subsume those features from the key set, as
specified by the features names you provide.
To use the annotation diff tool, see Section \ref{sec:eval:adiff}. To create
a gold standard, see section \ref{sec:eval:adiff:goldstandard}. To compare
more than two annotation sets, see Section
\ref{sec:developer:annotationsstackview}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:adiff]{Performing Evaluation with the Annotation Diff
Tool}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=14cm]{annotation-diff-statistics.png}
\end{center}
\caption{Annotation diff window with the parameters at the top,
the comparison table in the center and the statistics panel at the
bottom.}
\label{fig:annotdiff}
\end{figure}
The Annotation Diff tool is activated by selecting it from the Tools menu
at the top of the GATE Developer window. It will appear in a new
window. Select the key and response documents to be used (note that
both must have been previously loaded into the system), the annotation
sets to be used for each, and the annotation type to be compared.
Note that the tool automatically intersects all the annotation
types from the selected key annotation set with all types from the
response set.
On a separate note, you can perform a diff on the same document,
between two different annotation sets. One annotation set could
contain the key type and another could contain the response one.
After the type has been selected, the user is required to decide
how the features will be compared. It is important to know that
the tool compares them by analysing if features from the key set
are contained in the response set. It checks for both the feature
name and feature value to be the same.
There are three basic options to select:
\begin{itemize}
\item
To take `all' the features from the key set into consideration
\item
To take only `some' user selected features
\item
To take `none' of the features from the key set.
\end{itemize}
The weight for the F-Measure can also be changed - by default it is set to
1.0 (i.e. to give precision and recall equal weight). Finally, click on
`Compare' to display the results. Note that the window may need to be
resized manually, by dragging the window edges as appropriate).
In the main window, the key and response annotations will be
displayed. They can be sorted by any category by clicking on the
central column header: `=?'. The key and response annotations will be
aligned if their indices are identical, and are color coded
according to the legend displayed at the bottom.
Precision, recall, F-measure are also displayed below the annotation tables,
each according to 3 criteria - strict, lenient and average. See Sections
\ref{sec:eval:annotationdiff} and \ref{sec:eval:metrics} for more
details about the evaluation metrics.
The results can be saves to an HTML file by using the `Export to
HTML' button. This creates an HTML snapshot of what the Annotation Diff
table shows at that moment. The columns and rows in the table will
be shown in the same order, and the hidden columns will not appear in
the HTML file. The colours will also be the same.
If you need more details or context you can use the button `Show document'
to display the document and the annotations selected in the annotation diff
drop down lists and table.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:adiff:goldstandard]{Creating a Gold Standard with the
Annotation Diff Tool}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=14cm]{annotation-diff-adjudication.png}
\end{center}
\caption{Annotation diff window with the parameters at the top,
the comparison table in the center and the adjudication panel at the
bottom.}
\label{fig:annotdiff2}
\end{figure}
In order to create a gold standard set from two sets you need to show the
`Adjudication' panel at the bottom. It will insert two checkboxes columns in
the central table. Tick boxes in the columns `K(ey)' and `R(esponse)' then
input a Target set in the text field and use the `Copy selection to target'
button to copy all annotations selected to the target annotation set.
There is a context menu for the checkboxes to tick them quickly.
Each time you will copy the selection to the target set to create the gold
standard set, the rows will be hidden in further comparisons. In this way,
you will see only the annotations that haven't been processed. At the end of
the gold standard creation you should have an empty table.
To see again the copied rows, select the `Statistics' tab at the bottom and
use the button `Compare'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:adwarning]{A warning about feature values}
%
The Annotation Differ uses the Java \texttt{equals} test on the feature values
to determine whether they match. This test returns \texttt{false} (i.e., it
counts as a mismatch) if the values have different types, even if they look the
same in the user interface: for example, a \texttt{String} with a value of
\texttt{"5"} and an \texttt{Integer} with a value of \texttt{5} look the same on
the screen but do not match. Refer to the longer explanation in
Section~\ref{sec:eval:qawarning} for more detail and advice on preventing
mismatches.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\sect[sec:eval:corpusqualityassurance]{Corpus Quality Assurance}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=14cm]{corpusqa.png}
\end{center}
\caption{Corpus Quality Assurance showing the document statistics table}
\label{fig:corpusqa}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Description of the interface}
A bottom tab in each corpus view is entitled `Corpus Quality
Assurance'. This tab will allow you to calculate precision, recall and F-score
between two annotation sets in a corpus without the need to load a plugin. It
extends the Annotation Diff functionality to the entire corpus in a convenient
interface.
The main part of the view consists of two tabs each containing a table. One tab
is entitled `Corpus statistics' and the other is entitled `Document
statistics'.
To the right of the tabbed area is a configuration pane in which
you can select the annotation sets you wish to compare, the annotation types
you are interested in and the annotation features you wish to specify for use
in the calculation if any.
You can also choose whether to calculate agreement
on a strict or lenient basis or take the average of the two. (Recall that strict
matching requires two annotations to have an identical span if they are to be
considered a match, where lenient matching accepts a partial match; annotations
are overlapping but not identical in span.)
At the top, several icons are for opening a document (double-clicking on a
row is also working) or Annotation Diff only when a row in the document
statistics table is selected, exporting the tables to an HTML file,
reloading the list of sets, types and features when some documents have been
modified in the corpus and getting this help page.
Corpus Quality Assurance works also with a corpus inside a datastore. Using a
datastore is useful to minimise memory consumption when you have a big
corpus.
See the section~\ref{sec:eval:metrics} for more details about the evaluation
metrics.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Step by step usage}
Begin by selecting the annotation sets you wish to compare in the top list
in the configuration pane. Clicking on an annotation set labels it
annotation set A for the Key (an `(A)' will appear beside it to indicate
that this is your selection for annotation set A). Now click on another
annotation set. This will be labelled annotation set B for the response.
To change your selection, deselect an annotation set by
clicking on it a second time. You can now choose another annotation set. Note
that you do not need to hold the control key down to select the second
annotation set. This list is configured to accept two (and no more than two)
selections. If you wish, you may check the box `present in every document' to
reduce the annotation sets list to only those sets present in every document.
You may now choose the annotation types you are interested in. If you don't
choose any then all will be used. If you wish, you may check the box
`present in every selected set' to reduce the annotation types list to only
those present in every selected annotation set.
You can choose the annotation features you wish to include in the
calculation. If you choose features, then for an annotation to be considered
a match to another, their feature values must also match. If you select the
box `present in every selected type' the features list will be reduced to
only those present in every type you selected.
For the classification measures you must select only one type and one feature.
The `Measures' list allows you to choose whether to calculate strict or lenient
figures or average the two. You may choose as many as you wish, and they will
be included as columns in the table to the left. The BDM measures allow to
accept a match when the two concept are close enough in an ontology even if
their name are different. See section~\ref{sec:eval:bdmplugin}.
An `Options' button above the `Measures' list gives let you set some
settings like the beta for the Fscore or the BDM file.
Finally, click on the `Compare' button to recalculate the tables. The figures
that appear in the several tables (one per tab) are described below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Details of the Corpus statistics table}
In this table you will see that one row appears for every annotation type
you chose. Columns give total counts for matching annotations (`Match'
equivalent to TREC Correct), annotations only present in annotation set
A/Key (`Only A' equivalent to TREC Missing), annotations only present in
annotation set B/Response (`Only B' equivalent to TREC Spurious) and
annotations that overlapped (`Overlap' equivalent to TREC Partial).
Depending on whether one of your annotation sets is considered a
gold standard, you might prefer to think of `Only A' as missing and `Only B' as
spurious, or vice versa, but the Corpus Quality Assurance tool makes no
assumptions about which if any annotation set is the gold standard. Where it is
being used to calculate Inter Annotator Agreement there is no concept of a
`correct' set. However, in `MUC' terms, `Match' would be correct and `Overlap'
would be partial.
After these columns, three columns appear for every measure
you chose to calculate. If you chose to calculate a strict F1, a recall,
precision and F1 column will appear for the strict counts. If you chose to
calculate a lenient F1, precision, recall and F1 columns will also appear for
lenient counts.
In the corpus statistics table, calculations are done on a per type
basis and include all documents in the calculation. Final rows in the table
provide summaries; total counts are given along with a micro and a macro average.
Micro averaging treats the entire corpus as one big document where macro
averaging, on this table, is the arithmetic mean of the per-type figures. See
Section~\ref{sec:eval:macromicro} for more detail on the distinction between a
micro and a macro average.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Details of the Document statistics table}
In this table you will see that one row appears for
every document in the corpus. Columns give counts as in the corpus statistics
table, but this time on a per-document basis.
As before, for every measure you
choose to calculate, precision, recall and F1 columns will appear in the table.
Summary rows, again, give a macro average (arithmetic mean of the per-document
measures) and micro average (identical to the figure in the corpus
statistics table).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{GATE Embedded API for the measures}
You can get the same results as the Corpus Quality Assurance tool from your
program by using the classes that compute the results.
They are three for the moment:
\htlink{http://gate.ac.uk/gate/src/gate/util/AnnotationDiffer.java}
{AnnotationDiffer},
\htlink{http://gate.ac.uk/gate/src/gate/util/ClassificationMeasures.java}
{ClassificationMeasures} and
\htlink{http://gate.ac.uk/gate/src/gate/util/OntologyMeasures.java}
{OntologyMeasures}. All in gate.util package.
To compute the measures respect the order below.
Constructors and methods to initialise the measure objects:
\begin{small}
\begin{verbatim}
AnnotationDiffer differ = new AnnotationDiffer();
differ.setSignificantFeaturesSet(Set<String> features);
ClassificationMeasures classificationMeasures = new ClassificationMeasures();
OntologyMeasures ontologyMeasures = new OntologyMeasures();
ontologyMeasures.setBdmFile(URL bdmFileUrl);
\end{verbatim}\end{small}
With bdmFileUrl an URL to a file of the format described at
section~\ref{sec:eval:bdmplugin}.
Methods for computing the measures:
\begin{small}\begin{verbatim}
differ.calculateDiff(Collection key, Collection response)
classificationMeasures.calculateConfusionMatrix(AnnotationSet key,
AnnotationSet response, String type, String feature, boolean verbose)
ontologyMeasures.calculateBdm(Collection<AnnotationDiffer> differs)
\end{verbatim}\end{small}
With verbose to be set to true if you want to get printed the annotations
ignored on the "standard" output stream.
Constructors, useful for micro average, no need to use calculateX methods
as they must have been already called:
\begin{small}
\begin{verbatim}
AnnotationDiffer(Collection<AnnotationDiffer> differs)
ClassificationMeasures(Collection<ClassificationMeasures> tables)
OntologyMeasures(Collection<OntologyMeasures> measures)
\end{verbatim}\end{small}
Method for getting results for all 3 classes:
\begin{small}\begin{verbatim}
List<String> getMeasuresRow(Object[] measures, String title)
\end{verbatim}\end{small}
With measures an array of String with values to choose from:
\begin{itemize}
\item F1.0-score strict
\item F1.0-score lenient
\item F1.0-score average
\item F1.0-score strict BDM
\item F1.0-score lenient BDM
\item F1.0-score average BDM
\item Observed agreement
\item Cohen's Kappa
\item Pi's Kappa
\end{itemize}
Note that the numeric value `1.0' represents the beta coefficient in the Fscore.
See section~\ref{sec:eval:metrics} for more information on these measures.
Method only for ClassificationMeasures:
\begin{small}
\begin{verbatim}
List<List<String>> getConfusionMatrix(String title)
\end{verbatim}\end{small}
The following example is taken from
\htlink{http://gate.ac.uk/gate/src/gate/gui/CorpusQualityAssurance.java}
{gate.gui.CorpusQualityAssurance\#compareAnnotation} but hasn't been ran so
there could be some corrections to make.
\begin{lstlisting}
final int FSCORE_MEASURES = 0;
final int CLASSIFICATION_MEASURES = 1;
ArrayList<String> documentNames = new ArrayList<String>();
TreeSet<String> types = new TreeSet<String>();
Set<String> features = new HashSet<String>();
int measuresType = FSCORE_MEASURES;
Object[] measures = new Object[]
{"F1.0-score strict", "F0.5-score lenient BDM"};
String keySetName = "Key";
String responseSetName = "Response";
types.add("Person");
features.add("gender");
URL bdmFileUrl = null;
try {
bdmFileUrl = new URL("file:///tmp/bdm.txt");
} catch (MalformedURLException e) {
e.printStackTrace();
}
boolean useBdm = false;
for (Object measure : measures) {
if (((String) measure).contains("BDM")) { useBdm = true; break; }
}
// for each document
for (int row = 0; row < corpus.size(); row++) {
boolean documentWasLoaded = corpus.isDocumentLoaded(row);
Document document = (Document) corpus.get(row);
documentNames.add(document.getName());
Set<Annotation> keys = new HashSet<Annotation>();
Set<Annotation> responses = new HashSet<Annotation>();
// get annotations from selected annotation sets
keys = document.getAnnotations(keySetName);
responses = document.getAnnotations(responseSetName);
if (!documentWasLoaded) { // in case of datastore
corpus.unloadDocument(document);
Factory.deleteResource(document);
}
// fscore document table
if (measuresType == FSCORE_MEASURES) {
HashMap<String, AnnotationDiffer> differsByType =
new HashMap<String, AnnotationDiffer>();
AnnotationDiffer differ;
Set<Annotation> keysIter = new HashSet<Annotation>();
Set<Annotation> responsesIter = new HashSet<Annotation>();
for (String type : types) {
if (!keys.isEmpty() && !types.isEmpty()) {
keysIter = ((AnnotationSet)keys).get(type);
}
if (!responses.isEmpty() && !types.isEmpty()) {
responsesIter = ((AnnotationSet)responses).get(type);
}
differ = new AnnotationDiffer();
differ.setSignificantFeaturesSet(features);
differ.calculateDiff(keysIter, responsesIter); // compare
differsByType.put(type, differ);
}
differsByDocThenType.add(differsByType);
differ = new AnnotationDiffer(differsByType.values());
List<String> measuresRow;
if (useBdm) {
OntologyMeasures ontologyMeasures = new OntologyMeasures();
ontologyMeasures.setBdmFile(bdmFileUrl);
ontologyMeasures.calculateBdm(differsByType.values());
measuresRow = ontologyMeasures.getMeasuresRow(
measures, documentNames.get(documentNames.size()-1));
} else {
measuresRow = differ.getMeasuresRow(measures,
documentNames.get(documentNames.size()-1));
}
System.out.println(Arrays.deepToString(measuresRow.toArray()));
// classification document table
} else if (measuresType == CLASSIFICATION_MEASURES
&& !keys.isEmpty() && !responses.isEmpty()) {
ClassificationMeasures classificationMeasures =
new ClassificationMeasures();
classificationMeasures.calculateConfusionMatrix(
(AnnotationSet) keys, (AnnotationSet) responses,
types.first(), features.iterator().next(), false);
List<String> measuresRow = classificationMeasures.getMeasuresRow(
measures, documentNames.get(documentNames.size()-1));
System.out.println(Arrays.deepToString(measuresRow.toArray()));
List<List<String>> matrix = classificationMeasures
.getConfusionMatrix(documentNames.get(documentNames.size()-1));
for (List<String> matrixRow : matrix) {
System.out.println(Arrays.deepToString(matrixRow.toArray()));
}
}
}
\end{lstlisting}
See method
\htlink{http://gate.ac.uk/gate/src/gate/gui/CorpusQualityAssurance.java}
{gate.gui.CorpusQualityAssurance\#printSummary} for micro and macro average
like in the Corpus Quality Assurance.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:qawarning]{A warning about feature values}
%
The F-measure, precision, and recall measures, and the counts of matches used to
produce them, are based on the Java \texttt{equals} test on the feature values
being compared. This test returns \texttt{false} (i.e., it counts as a
mismatch) if the values have different types, even if they look the same in the
user interface: for example, a \texttt{String} with a value of \texttt{"5"} and
an \texttt{Integer} with a value of \texttt{5} look the same on the screen but
do not match.
The values of GATE features (for documents as well as annotations) are
automatically stored as \texttt{String} values whenever you change them in the
GUI feature editor. For example, if you click in a feature with an
\texttt{Integer} with a value of \texttt{5} and type another digit, the result
will be stored as a \texttt{String} (e.g., \texttt{"56"}, but it will look like
\texttt{56} in the GUI). The current version of GATE does not change feature
values to \texttt{String} if you click in the value text box but do not change
anything. (Earlier versions made the change if you clicked in the text box.)
In order to get correct results, you need to ensure that the values of the
\emph{key} and \emph{response} features being compared have the same type. If
this is not certain to be the case, you may wish to add a JAPE or Groovy PR to
check the types of the feature values and convert them all to one type (e.g.,
\texttt{String} or \texttt{Integer}).
The classification and confusion matrix tables in the Corpus QA display are
produced a different way, by assembling a list of all the feature values,
converting them to strings to create the row and column headers, and then
incrementing the cells in the table according to the string conversion. In
these tables, a \texttt{String} with a value of \texttt{"5"} and an
\texttt{Integer} with a value of \texttt{5} count as a match.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:qapr]{Quality Assurance PR}
We have also implemented a processing resource called Quality Assurance PR that
wraps the functionality of the QA Tool. At the time of writing this
documentation, the only difference the QA PR has in terms of functionality is
that the PR only accepts one measure at a time.
The Quality Assuarance PR is included in the Tools plugin. The PR can be added
to any existing corpus pipeline. Since the QA tool works on the entire corpus,
the PR has to be executed after all the documents in the corpus have been
processed. In order to achieve this, we have designed the PR in such a way that
it only gets executed when the pipeline reaches to the last document in the
corpus. There are no init-time parameters but users are required to provide
values for the following run-time parameters.
\begin{itemize}
\item annotationTypes - annotation types to compare.
\item featuresNames - features of the annotation types (specified above) to
compare.
\item keyASName - the annotation set that acts as a gold standard set and
contains annotations of the types specified above in the first parameter.
\item responseASName - the annotation set that acts as a test set and contains
annotations of the types specified above in the first parameter.
\item measure - one of the six pre-defined measures: F1\_STRICT, F1\_AVERAGE,
F1\_LENIENT, F05\_STRICT, F05\_AVERAGE and F05\_LENIENT.
\item outputFolderUrl - the PR produces two html files in the folder mentioned
in this parameter. The files are document-stats.html and the corpus-stats.html.
The former lists statistics for each document and the latter lists statistics
for each annotation type in the corpus. In case of the document-stats.html, each
document is linked with an html file that contains the output of the
annotation diff utility in GATE.
\end{itemize}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\sect[sec:eval:benchmarktool]{Corpus Benchmark Tool}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Like the Corpus Quality Assurance functionality, the corpus benchmark tool
enables evaluation to be carried out over a whole corpus rather than a
single document. Unlike Corpus QA, it uses matched corpora to achieve this,
rather than comparing annotation sets within a corpus. It enables tracking of the
system's performance over time. It provides more detailed information regarding
the annotations that differ between versions of the corpus (e.g. annotations
created by different versions of an application) than the Corpus QA tool does.
% The tool can be run either from GATE Developer or the command line.
The basic idea with the tool is to evaluate an application with respect to a
`gold standard'. You have a `marked' corpus containing the gold standard
reference annotations; you have a `clean' copy of the corpus that does not
contain the annotations in question, and you have an application that creates the
annotations in question. Now you can see how you are getting on, by comparing the
result of running your application on `clean' to the `marked' annotations.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:preparing-benchmarktool]{Preparing the Corpora for Use}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
You will need to prepare the following directory structure:
\begin{small}
\begin{verbatim}
main directory (can have any name)
|
|__"clean" (directory containing unannotated documents in XML form)
|
|__"marked" (directory containing annotated documents in XML form)
|
|__"processed" (directory containing the datastore which is generated
when you `store corpus for future evaluation')
\end{verbatim}\end{small}
\begin{itemize}
\item {\bf main}: you should have a main directory containing subdirectories for
your matched corpora. It does not matter what this directory is called. This
is the directory you will select when the program prompts, `Please select a
directory which contains the documents to be evaluated'.
\item {\bf clean}: Make a directory called `clean' (case-sensitive), and in it,
make a copy of your corpus that does not contain the annotations that your
application creates (though it may contain other annotations). The corpus
benchmark tool will apply your application to this corpus, so it is important
that the annotations it creates are not already present in the corpus. You can
create this corpus by copying your `marked' corpus and deleting the annotations
in question from it.
\item {\bf marked}: you should have a `gold standard' copy of your corpus in a
directory called `marked' (case-sensitive), containing the annotations to which
the program will compare those produced by your application. The idea of the
corpus benchmark tool is to tell you how good your application performance is relative
to this annotation set. The `marked' corpus should contain exactly the same
documents as the `clean' set.
\item {\bf processed}: this directory contains a third version of the corpus.
This directory will be created by the tool itself, when you run `store corpus for
future evaluation'. We will explain how to do this in
Section~\ref{sec:eval:howto-benchmarktool}
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsect[sec:eval:corpustoolproperties]{Defining Properties}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The properties of the corpus benchmark tool are defined in the file
`corpus\_tool.properties', which should be located in the GATE home directory. GATE
will tell you where it's looking for the properties file in the `message' panel
when you run the Corpus Benchmark Tool. It is important to prepare this file
before attempting to run the tool because there is no file present by default, so
unless you prepare this file, the corpus benchmark tool will not work!