A utility class for scoring chunk parsers. ChunkScore can evaluate a chunk parser's output, based on a number of statistics (precision, recall, f-measure, misssed chunks, incorrect chunks). It can also combine the scores from the parsing of multiple texts; this makes it significantly easier to evaluate a chunk parser that operates one sentence at a time.
Texts are evaluated with the score method. The results of evaluation can be accessed via a number of accessor methods, such as precision and f_measure. A typical use of the ChunkScore class is:
>>> chunkscore = ChunkScore() # doctest: +SKIP >>> for correct in correct_sentences: # doctest: +SKIP ... guess = chunkparser.parse(correct.leaves()) # doctest: +SKIP ... chunkscore.score(correct, guess) # doctest: +SKIP >>> print('F Measure:', chunkscore.f_measure()) # doctest: +SKIP F Measure: 0.823
Method | __init__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | __repr__ |
Return a concise representation of this ChunkScoring. |
Method | __str__ |
Return a verbose representation of this ChunkScoring. This representation includes the precision, recall, and f-measure scores. For other information about the score, use the accessor methods (e.g., missed()... |
Method | accuracy |
Return the overall tag-based accuracy for all text that have been scored by this ChunkScore, using the IOB (conll2000) tag encoding. |
Method | correct |
Return the chunks which were included in the correct chunk structures, listed in input order. |
Method | f |
Return the overall F measure for all texts that have been scored by this ChunkScore. |
Method | guessed |
Return the chunks which were included in the guessed chunk structures, listed in input order. |
Method | incorrect |
Return the chunks which were included in the guessed chunk structures, but not in the correct chunk structures, listed in input order. |
Method | missed |
Return the chunks which were included in the correct chunk structures, but not in the guessed chunk structures, listed in input order. |
Method | precision |
Return the overall precision for all texts that have been scored by this ChunkScore. |
Method | recall |
Return the overall recall for all texts that have been scored by this ChunkScore. |
Method | score |
Given a correctly chunked sentence, score another chunked version of the same sentence. |
Instance Variable | kwargs |
Keyword arguments: |
Method | _update |
Undocumented |
Instance Variable | _chunk |
Undocumented |
Instance Variable | _correct |
Undocumented |
Instance Variable | _count |
Undocumented |
Instance Variable | _fn |
List of false negatives |
Instance Variable | _fn |
Number of false negatives. |
Instance Variable | _fp |
List of false positives |
Instance Variable | _fp |
Number of false positives |
Instance Variable | _guessed |
Undocumented |
Instance Variable | _max |
Undocumented |
Instance Variable | _max |
Undocumented |
Instance Variable | _max |
Undocumented |
Instance Variable | _measures |
Undocumented |
Instance Variable | _tags |
Undocumented |
Instance Variable | _tags |
Undocumented |
Instance Variable | _tp |
List of true positives |
Instance Variable | _tp |
Number of true positives |
Return a verbose representation of this ChunkScoring. This representation includes the precision, recall, and f-measure scores. For other information about the score, use the accessor methods (e.g., missed() and incorrect()).
Returns | |
str | Undocumented |
Return the overall tag-based accuracy for all text that have been scored by this ChunkScore, using the IOB (conll2000) tag encoding.
Returns | |
float | Undocumented |
Return the chunks which were included in the correct chunk structures, listed in input order.
Returns | |
list of chunks | Undocumented |
Return the overall F measure for all texts that have been scored by this ChunkScore.
Parameters | |
alpha:float | the relative weighting of precision and recall. Larger alpha biases the score towards the precision value, while smaller alpha biases the score towards the recall value. alpha should have a value in the range [0,1]. |
Returns | |
float | Undocumented |
Return the chunks which were included in the guessed chunk structures, listed in input order.
Returns | |
list of chunks | Undocumented |
Return the chunks which were included in the guessed chunk structures, but not in the correct chunk structures, listed in input order.
Returns | |
list of chunks | Undocumented |
Return the chunks which were included in the correct chunk structures, but not in the guessed chunk structures, listed in input order.
Returns | |
list of chunks | Undocumented |
Return the overall precision for all texts that have been scored by this ChunkScore.
Returns | |
float | Undocumented |
Return the overall recall for all texts that have been scored by this ChunkScore.
Returns | |
float | Undocumented |
Given a correctly chunked sentence, score another chunked version of the same sentence.
Parameters | |
correct:chunk structure | The known-correct ("gold standard") chunked sentence. |
guessed:chunk structure | The chunked sentence to be scored. |
Keyword arguments:
- max_tp_examples: The maximum number actual examples of true positives to record. This affects the correct member function: correct will not return more than this number of true positive examples. This does not affect any of the numerical metrics (precision, recall, or f-measure)
- max_fp_examples: The maximum number actual examples of false positives to record. This affects the incorrect member function and the guessed member function: incorrect will not return more than this number of examples, and guessed will not return more than this number of true positive examples. This does not affect any of the numerical metrics (precision, recall, or f-measure)
- max_fn_examples: The maximum number actual examples of false negatives to record. This affects the missed member function and the correct member function: missed will not return more than this number of examples, and correct will not return more than this number of true negative examples. This does not affect any of the numerical metrics (precision, recall, or f-measure)
- chunk_label: A regular expression indicating which chunks should be compared. Defaults to '.*' (i.e., all chunks).