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: Given a value in the confusion matrix, return the precision
  that corresponds to this value. The precision is defined as:
  
  - *p* = true positive / (true positive + false negative)
  
  and can loosely be considered the ratio of how often ``value``
  was predicted correctly relative to the number of predictions
  for ``value``.
  
  :param value: value used in the ConfusionMatrix
  :return: the precision corresponding to ``value``.
  :rtype: float
docstr_tok: ["Given","a","value","in","the","confusion","matrix",",","return","the","precision","that","corresponds","to","this","value",".","The","precision","is","defined","as",":","-","*","p","*","=","true","positive","\/","(","true","positive","+","false","negative",")","and","can","loosely","be","considered","the","ratio","of","how","often","``","value","``","was","predicted","correctly","relative","to","the","number","of","predictions","for","``","value","``",".",":","param","value",":","value","used","in","the","ConfusionMatrix",":","return",":","the","precision","corresponding","to","``","value","``",".",":","rtype",":","float"]
code: def precision(self, value):
      """Given a value in the confusion matrix, return the precision
      that corresponds to this value. The precision is defined as:
  
      - *p* = true positive / (true positive + false negative)
  
      and can loosely be considered the ratio of how often ``value``
      was predicted correctly relative to the number of predictions
      for ``value``.
  
      :param value: value used in the ConfusionMatrix
      :return: the precision corresponding to ``value``.
      :rtype: float
      """
      # Number of times `value` was correct, and also predicted
      TP = self[value, value]
      # Number of times `value` was predicted
      TP_FP = sum(
          self[real_value, value] for real_value in self._values
      )
      if TP_FP == 0:
          return 0.0
      return TP / TP_FP
  
file_path: nltk/nltk/metrics/confusionmatrix.py
imports: from nltk.probability import FreqDist
label_desc: Use image node_id 8 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.precision(value) and returns: unknown, int