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 used in the confusion matrix, return the f-measure
  that corresponds to this value. The f-measure is the harmonic mean
  of the ``precision`` and ``recall``, weighted by ``alpha``.
  In particular, given the precision *p* and recall *r* defined by:
  
  - *p* = true positive / (true positive + false negative)
  - *r* = true positive / (true positive + false positive)
  
  The f-measure is:
  
  - *1/(alpha/p + (1-alpha)/r)*
  
  With ``alpha = 0.5``, this reduces to:
  
  - *2pr / (p + r)*
  
  :param value: value used in the ConfusionMatrix
  :param alpha: Ratio of the cost of false negative compared to false
      positives. Defaults to 0.5, where the costs are equal.
  :type alpha: float
  :return: the F-measure corresponding to ``value``.
  :rtype: float
docstr_tok: ["Given","a","value","used","in","the","confusion","matrix",",","return","the","f-measure","that","corresponds","to","this","value",".","The","f-measure","is","the","harmonic","mean","of","the","``","precision","``","and","``","recall","``",",","weighted","by","``","alpha","``",".","In","particular",",","given","the","precision","*","p","*","and","recall","*","r","*","defined","by",":","-","*","p","*","=","true","positive","\/","(","true","positive","+","false","negative",")","-","*","r","*","=","true","positive","\/","(","true","positive","+","false","positive",")","The","f-measure","is",":","-","*","1\/","(","alpha\/p","+","(","1-alpha",")","\/r",")","*","With","``","alpha","=","0.5","``",",","this","reduces","to",":","-","*","2pr","\/","(","p","+","r",")","*",":","param","value",":","value","used","in","the","ConfusionMatrix",":","param","alpha",":","Ratio","of","the","cost","of","false","negative","compared","to","false","positives",".","Defaults","to","0.5",",","where","the","costs","are","equal",".",":","type","alpha",":","float",":","return",":","the","F-measure","corresponding","to","``","value","``",".",":","rtype",":","float"]
code: def f_measure(self, value, alpha=0.5):
      """
      Given a value used in the confusion matrix, return the f-measure
      that corresponds to this value. The f-measure is the harmonic mean
      of the ``precision`` and ``recall``, weighted by ``alpha``.
      In particular, given the precision *p* and recall *r* defined by:
  
      - *p* = true positive / (true positive + false negative)
      - *r* = true positive / (true positive + false positive)
  
      The f-measure is:
  
      - *1/(alpha/p + (1-alpha)/r)*
  
      With ``alpha = 0.5``, this reduces to:
  
      - *2pr / (p + r)*
  
      :param value: value used in the ConfusionMatrix
      :param alpha: Ratio of the cost of false negative compared to false
          positives. Defaults to 0.5, where the costs are equal.
      :type alpha: float
      :return: the F-measure corresponding to ``value``.
      :rtype: float
      """
      p = self.precision(value)
      r = self.recall(value)
      if p == 0.0 or r == 0.0:
          return 0.0
      return 1.0 / (alpha / p + (1 - alpha) / r)
  
file_path: nltk/nltk/metrics/confusionmatrix.py
imports: from nltk.probability import FreqDist
label_desc: Use image node_id 9 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.f_measure(value, alpha) and returns: unknown, int