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: :return: A multi-line string representation of this confusion matrix.
  :type truncate: int
  :param truncate: If specified, then only show the specified
      number of values.  Any sorting (e.g., sort_by_count)
      will be performed before truncation.
  :param sort_by_count: If true, then sort by the count of each
      label in the reference data.  I.e., labels that occur more
      frequently in the reference label will be towards the left
      edge of the matrix, and labels that occur less frequently
      will be towards the right edge.
  
  @todo: add marginals?
docstr_tok: [":","return",":","A","multi-line","string","representation","of","this","confusion","matrix",".",":","type","truncate",":","int",":","param","truncate",":","If","specified",",","then","only","show","the","specified","number","of","values",".","Any","sorting","(","e.g.",",","sort_by_count",")","will","be","performed","before","truncation",".",":","param","sort_by_count",":","If","true",",","then","sort","by","the","count","of","each","label","in","the","reference","data",".","I.e.",",","labels","that","occur","more","frequently","in","the","reference","label","will","be","towards","the","left","edge","of","the","matrix",",","and","labels","that","occur","less","frequently","will","be","towards","the","right","edge",".","@","todo",":","add","marginals","?"]
code: def pretty_format(
      self,
      show_percents=False,
      values_in_chart=True,
      truncate=None,
      sort_by_count=False,
  ):
      """
      :return: A multi-line string representation of this confusion matrix.
      :type truncate: int
      :param truncate: If specified, then only show the specified
          number of values.  Any sorting (e.g., sort_by_count)
          will be performed before truncation.
      :param sort_by_count: If true, then sort by the count of each
          label in the reference data.  I.e., labels that occur more
          frequently in the reference label will be towards the left
          edge of the matrix, and labels that occur less frequently
          will be towards the right edge.
  
      @todo: add marginals?
      """
      confusion = self._confusion
  
      values = self._values
      if sort_by_count:
          values = sorted(
              values,
              key=lambda v: -sum(self._confusion[self._indices[v]]),
          )
  
      if truncate:
          values = values[:truncate]
  
      if values_in_chart:
          value_strings = ["%s" % val for val in values]
      else:
          value_strings = [str(n + 1) for n in range(len(values))]
  
      # Construct a format string for row values
      valuelen = max(len(val) for val in value_strings)
      value_format = "%" + repr(valuelen) + "s | "
      # Construct a format string for matrix entries
      if show_percents:
          entrylen = 6
          entry_format = "%5.1f%%"
          zerostr = "     ."
      else:
          entrylen = len(repr(self._max_conf))
          entry_format = "%" + repr(entrylen) + "d"
          zerostr = " " * (entrylen - 1) + "."
  
      # Write the column values.
      s = ""
      for i in range(valuelen):
          s += (" " * valuelen) + " |"
          for val in value_strings:
              if i >= valuelen - len(val):
                  s += val[i - valuelen + len(val)].rjust(entrylen + 1)
              else:
                  s += " " * (entrylen + 1)
          s += " |\n"
  
      # Write a dividing line
      s += "{}-+-{}+\n".format(
          "-" * valuelen, "-" * ((entrylen + 1) * len(values))
      )
  
      # Write the entries.
      for val, li in zip(value_strings, values):
          i = self._indices[li]
          s += value_format % val
          for lj in values:
              j = self._indices[lj]
              if confusion[i][j] == 0:
                  s += zerostr
              elif show_percents:
                  s += entry_format % (
                      100.0 * confusion[i][j] / self._total
                  )
              else:
                  s += entry_format % confusion[i][j]
              if i == j:
                  prevspace = s.rfind(" ")
                  s = s[:prevspace] + "<" + s[prevspace + 1 :] + ">"
              else:
                  s += " "
          s += "|\n"
  
      # Write a dividing line
      s += "{}-+-{}+\n".format(
          "-" * valuelen, "-" * ((entrylen + 1) * len(values))
      )
  
      # Write a key
      s += "(row = reference; col = test)\n"
      if not values_in_chart:
          s += "Value key:\n"
          for i, value in enumerate(values):
              s += "%6d: %s\n" % (i + 1, value)
  
      return s
  
file_path: nltk/nltk/metrics/confusionmatrix.py
imports: from nltk.probability import FreqDist
label_desc: Use image node_id 5 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.pretty_format(show_percents, values_in_chart, truncate, sort_by_count) and returns: s