class_docstr: The confusion matrix between a list of reference values and a
  corresponding list of test values.  Entry *[r,t]* of this
  matrix is a count of the number of times that the reference value
  *r* corresponds to the test value *t*.  E.g.:
  
      >>> from nltk.metrics import ConfusionMatrix
      >>> ref  = 'DET NN VB DET JJ NN NN IN DET NN'.split()
      >>> test = 'DET VB VB DET NN NN NN IN DET NN'.split()
      >>> cm = ConfusionMatrix(ref, test)
      >>> print(cm['NN', 'NN'])
      3
  
  Note that the diagonal entries *Ri=Tj* of this matrix
  corresponds to correct values; and the off-diagonal entries
  correspond to incorrect values.
class_docstr_tok: ["The","confusion","matrix","between","a","list","of","reference","values","and","a","corresponding","list","of","test","values",".","Entry","*","[","r",",","t","]","*","of","this","matrix","is","a","count","of","the","number","of","times","that","the","reference","value","*","r","*","corresponds","to","the","test","value","*","t","*",".","E.g",".",":",">",">",">","from","nltk.metrics","import","ConfusionMatrix",">",">",">","ref","=","'DET","NN","VB","DET","JJ","NN","NN","IN","DET","NN'.split","(",")",">",">",">","test","=","'DET","VB","VB","DET","NN","NN","NN","IN","DET","NN'.split","(",")",">",">",">","cm","=","ConfusionMatrix","(","ref",",","test",")",">",">",">","print","(","cm","[","'NN","'",",","'NN","'","]",")","3","Note","that","the","diagonal","entries","*","Ri=Tj","*","of","this","matrix","corresponds","to","correct","values",";","and","the","off-diagonal","entries","correspond","to","incorrect","values","."]
docstr: Tabulate the **recall**, **precision** and **f-measure**
  for each value in this confusion matrix.
  
  >>> reference = "DET NN VB DET JJ NN NN IN DET NN".split()
  >>> test = "DET VB VB DET NN NN NN IN DET NN".split()
  >>> cm = ConfusionMatrix(reference, test)
  >>> print(cm.evaluate())
  Tag | Prec.  | Recall | F-measure
  ----+--------+--------+-----------
  DET | 1.0000 | 1.0000 | 1.0000
   IN | 1.0000 | 1.0000 | 1.0000
   JJ | 0.0000 | 0.0000 | 0.0000
   NN | 0.7500 | 0.7500 | 0.7500
   VB | 0.5000 | 1.0000 | 0.6667
  <BLANKLINE>
  
  :param alpha: Ratio of the cost of false negative compared to false
      positives, as used in the f-measure computation. Defaults to 0.5,
      where the costs are equal.
  :type alpha: float
  :param truncate: If specified, then only show the specified
      number of values. Any sorting (e.g., sort_by_count)
      will be performed before truncation. Defaults to None
  :type truncate: int, optional
  :param sort_by_count: Whether to sort the outputs on frequency
      in the reference label. Defaults to False.
  :type sort_by_count: bool, optional
  :return: A tabulated recall, precision and f-measure string
  :rtype: str
docstr_tok: ["Tabulate","the","*","*","recall","*","*",",","*","*","precision","*","*","and","*","*","f-measure","*","*","for","each","value","in","this","confusion","matrix",".",">",">",">","reference","=","``","DET","NN","VB","DET","JJ","NN","NN","IN","DET","NN","''",".split","(",")",">",">",">","test","=","``","DET","VB","VB","DET","NN","NN","NN","IN","DET","NN","''",".split","(",")",">",">",">","cm","=","ConfusionMatrix","(","reference",",","test",")",">",">",">","print","(","cm.evaluate","(",")",")","Tag","|","Prec",".","|","Recall","|","F-measure","--","--","+","--","--","--","--","+","--","--","--","--","+","--","--","--","--","--","-","DET","|","1.0000","|","1.0000","|","1.0000","IN","|","1.0000","|","1.0000","|","1.0000","JJ","|","0.0000","|","0.0000","|","0.0000","NN","|","0.7500","|","0.7500","|","0.7500","VB","|","0.5000","|","1.0000","|","0.6667","<","BLANKLINE",">",":","param","alpha",":","Ratio","of","the","cost","of","false","negative","compared","to","false","positives",",","as","used","in","the","f-measure","computation",".","Defaults","to","0.5",",","where","the","costs","are","equal",".",":","type","alpha",":","float",":","param","truncate",":","If","specified",",","then","only","show","the","specified","number","of","values",".","Any","sorting","(","e.g.",",","sort_by_count",")","will","be","performed","before","truncation",".","Defaults","to","None",":","type","truncate",":","int",",","optional",":","param","sort_by_count",":","Whether","to","sort","the","outputs","on","frequency","in","the","reference","label",".","Defaults","to","False",".",":","type","sort_by_count",":","bool",",","optional",":","return",":","A","tabulated","recall",",","precision","and","f-measure","string",":","rtype",":","str"]
code: def evaluate(self, alpha=0.5, truncate=None, sort_by_count=False):
      """
      Tabulate the **recall**, **precision** and **f-measure**
      for each value in this confusion matrix.
  
      >>> reference = "DET NN VB DET JJ NN NN IN DET NN".split()
      >>> test = "DET VB VB DET NN NN NN IN DET NN".split()
      >>> cm = ConfusionMatrix(reference, test)
      >>> print(cm.evaluate())
      Tag | Prec.  | Recall | F-measure
      ----+--------+--------+-----------
      DET | 1.0000 | 1.0000 | 1.0000
       IN | 1.0000 | 1.0000 | 1.0000
       JJ | 0.0000 | 0.0000 | 0.0000
       NN | 0.7500 | 0.7500 | 0.7500
       VB | 0.5000 | 1.0000 | 0.6667
      <BLANKLINE>
  
      :param alpha: Ratio of the cost of false negative compared to false
          positives, as used in the f-measure computation. Defaults to 0.5,
          where the costs are equal.
      :type alpha: float
      :param truncate: If specified, then only show the specified
          number of values. Any sorting (e.g., sort_by_count)
          will be performed before truncation. Defaults to None
      :type truncate: int, optional
      :param sort_by_count: Whether to sort the outputs on frequency
          in the reference label. Defaults to False.
      :type sort_by_count: bool, optional
      :return: A tabulated recall, precision and f-measure string
      :rtype: str
      """
      tags = self._values
  
      # Apply keyword parameters
      if sort_by_count:
          tags = sorted(
              tags,
              key=lambda v: -sum(self._confusion[self._indices[v]]),
          )
      if truncate:
          tags = tags[:truncate]
  
      tag_column_len = max(max(len(tag) for tag in tags), 3)
  
      # Construct the header
      s = (
          f"{' ' * (tag_column_len - 3)}Tag | Prec.  | Recall | F-measure\n"
          f"{'-' * tag_column_len}-+--------+--------+-----------\n"
      )
  
      # Construct the body
      for tag in tags:
          s += (
              f"{tag:>{tag_column_len}} | "
              f"{self.precision(tag):<6.4f} | "
              f"{self.recall(tag):<6.4f} | "
              f"{self.f_measure(tag, alpha=alpha):.4f}\n"
          )
  
      return s
  
file_path: nltk/nltk/metrics/confusionmatrix.py
imports: from nltk.probability import FreqDist
label_desc: Use image node_id 10 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.evaluate(alpha, truncate, sort_by_count) and returns: s