Package nltk_lite :: Package parse :: Module chunk :: Class ChunkScore
[show private | hide private]
[frames | no frames]

Type ChunkScore

object --+
         |
        ChunkScore


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 signifigantly 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()
   >>> for correct in correct_sentences:
   ...     guess = chunkparser.parse(correct.leaves())
   ...     chunkscore.score(correct, guess)
   >>> print 'F Measure:', chunkscore.f_measure()
   F Measure: 0.823

Method Summary
  __init__(self, **kwargs)
  __len__(self)
String __repr__(self)
Return a concise representation of this ChunkScoring.
String __str__(self)
Return a verbose representation of this ChunkScoring.
list of chunks correct(self)
Return the chunks which were included in the correct chunk structures, listed in input order.
float f_measure(self, alpha)
Return the overall F measure for all texts that have been scored by this ChunkScore.
list of chunks guessed(self)
Return the chunks which were included in the guessed chunk structures, listed in input order.
list of chunks incorrect(self)
Return the chunks which were included in the guessed chunk structures, but not in the correct chunk structures, listed in input order.
list of chunks missed(self)
Return the chunks which were included in the correct chunk structures, but not in the guessed chunk structures, listed in input order.
float precision(self)
Return the overall precision for all texts that have been scored by this ChunkScore.
float recall(self)
Return the overall recall for all texts that have been scored by this ChunkScore.
  score(self, correct, guessed)
Given a correctly chunked sentence, score another chunked version of the same sentence.
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Instance Variable Summary
  kwargs: Keyword arguments:

Method Details

__repr__(self)
(Representation operator)

Returns:
a concise representation of this ChunkScoring.
           (type=String)
Overrides:
__builtin__.object.__repr__

__str__(self)
(Informal representation operator)

Returns:
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()).
           (type=String)
Overrides:
__builtin__.object.__str__

correct(self)

Returns:
the chunks which were included in the correct chunk structures, listed in input order.
           (type=list of chunks)

f_measure(self, alpha=0.5)

Parameters:
alpha - 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].
           (type=float)
Returns:
the overall F measure for all texts that have been scored by this ChunkScore.
           (type=float)

guessed(self)

Returns:
the chunks which were included in the guessed chunk structures, listed in input order.
           (type=list of chunks)

incorrect(self)

Returns:
the chunks which were included in the guessed chunk structures, but not in the correct chunk structures, listed in input order.
           (type=list of chunks)

missed(self)

Returns:
the chunks which were included in the correct chunk structures, but not in the guessed chunk structures, listed in input order.
           (type=list of chunks)

precision(self)

Returns:
the overall precision for all texts that have been scored by this ChunkScore.
           (type=float)

recall(self)

Returns:
the overall recall for all texts that have been scored by this ChunkScore.
           (type=float)

score(self, correct, guessed)

Given a correctly chunked sentence, score another chunked version of the same sentence.
Parameters:
correct - The known-correct ("gold standard") chunked sentence.
           (type=chunk structure)
guessed - The chunked sentence to be scored.
           (type=chunk structure)

Instance Variable Details

kwargs

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)

Generated by Epydoc 2.1 on Tue Sep 5 09:37:22 2006 http://epydoc.sf.net