class_docstr: Computes F-Beta score.
  
  It is the weighted harmonic mean of precision
  and recall. Output range is `[0, 1]`. Works for
  both multi-class and multi-label classification.
  
  $$
  F_{\beta} = (1 + \beta^2) * \frac{\textrm{precision} * \textrm{recall}}{(\beta^2 \cdot \textrm{precision}) + \textrm{recall}}
  $$
  
  Args:
      num_classes: Number of unique classes in the dataset.
      average: Type of averaging to be performed on data.
          Acceptable values are `None`, `micro`, `macro` and
          `weighted`. Default value is None.
      beta: Determines the weight of precision and recall
          in harmonic mean. Determines the weight given to the
          precision and recall. Default value is 1.
      threshold: Elements of `y_pred` greater than threshold are
          converted to be 1, and the rest 0. If threshold is
          None, the argmax is converted to 1, and the rest 0.
      name: (Optional) String name of the metric instance.
      dtype: (Optional) Data type of the metric result.
  
  Returns:
      F-Beta Score: float.
  
  Raises:
      ValueError: If the `average` has values other than
      `[None, 'micro', 'macro', 'weighted']`.
  
      ValueError: If the `beta` value is less than or equal
      to 0.
  
  `average` parameter behavior:
  
      None: Scores for each class are returned.
  
      micro: True positivies, false positives and
          false negatives are computed globally.
  
      macro: True positivies, false positives and
          false negatives are computed for each class
          and their unweighted mean is returned.
  
      weighted: Metrics are computed for each class
          and returns the mean weighted by the
          number of true instances in each class.
  
  Usage:
  
  >>> metric = tfa.metrics.FBetaScore(num_classes=3, beta=2.0, threshold=0.5)
  >>> y_true = np.array([[1, 1, 1],
  ...                    [1, 0, 0],
  ...                    [1, 1, 0]], np.int32)
  >>> y_pred = np.array([[0.2, 0.6, 0.7],
  ...                    [0.2, 0.6, 0.6],
  ...                    [0.6, 0.8, 0.0]], np.float32)
  >>> metric.update_state(y_true, y_pred)
  >>> result = metric.result()
  >>> result.numpy()
  array([0.3846154 , 0.90909094, 0.8333334 ], dtype=float32)
class_docstr_tok: ["Computes","F-Beta","score",".","It","is","the","weighted","harmonic","mean","of","precision","and","recall",".","Output","range","is","`","[","0",",","1","]","`",".","Works","for","both","multi-class","and","multi-label","classification",".","$","$","F_","{","\\beta","}","=","(","1","+","\\beta^2",")","*","\\frac","{","\\textrm","{","precision","}","*","\\textrm","{","recall","}","}","{","(","\\beta^2","\\cdot","\\textrm","{","precision","}",")","+","\\textrm","{","recall","}","}","$","$","Args",":","num_classes",":","Number","of","unique","classes","in","the","dataset",".","average",":","Type","of","averaging","to","be","performed","on","data",".","Acceptable","values","are","`","None","`",",","`","micro","`",",","`","macro","`","and","`","weighted","`",".","Default","value","is","None",".","beta",":","Determines","the","weight","of","precision","and","recall","in","harmonic","mean",".","Determines","the","weight","given","to","the","precision","and","recall",".","Default","value","is","1.","threshold",":","Elements","of","`","y_pred","`","greater","than","threshold","are","converted","to","be","1",",","and","the","rest","0",".","If","threshold","is","None",",","the","argmax","is","converted","to","1",",","and","the","rest","0.","name",":","(","Optional",")","String","name","of","the","metric","instance",".","dtype",":","(","Optional",")","Data","type","of","the","metric","result",".","Returns",":","F-Beta","Score",":","float",".","Raises",":","ValueError",":","If","the","`","average","`","has","values","other","than","`","[","None",",","'micro","'",",","'macro","'",",","'weighted","'","]","`",".","ValueError",":","If","the","`","beta","`","value","is","less","than","or","equal","to","0",".","`","average","`","parameter","behavior",":","None",":","Scores","for","each","class","are","returned",".","micro",":","True","positivies",",","false","positives","and","false","negatives","are","computed","globally",".","macro",":","True","positivies",",","false","positives","and","false","negatives","are","computed","for","each","class","and","their","unweighted","mean","is","returned",".","weighted",":","Metrics","are","computed","for","each","class","and","returns","the","mean","weighted","by","the","number","of","true","instances","in","each","class",".","Usage",":",">",">",">","metric","=","tfa.metrics.FBetaScore","(","num_classes=3",",","beta=2.0",",","threshold=0.5",")",">",">",">","y_true","=","np.array","(","[","[","1",",","1",",","1","]",",","...","[","1",",","0",",","0","]",",","...","[","1",",","1",",","0","]","]",",","np.int32",")",">",">",">","y_pred","=","np.array","(","[","[","0.2",",","0.6",",","0.7","]",",","...","[","0.2",",","0.6",",","0.6","]",",","...","[","0.6",",","0.8",",","0.0","]","]",",","np.float32",")",">",">",">","metric.update_state","(","y_true",",","y_pred",")",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","array","(","[","0.3846154",",","0.90909094",",","0.8333334","]",",","dtype=float32",")"]
code: def result(self):
      precision = tf.math.divide_no_nan(
          self.true_positives,
          self.true_positives + self.false_positives,
      )
      recall = tf.math.divide_no_nan(
          self.true_positives,
          self.true_positives + self.false_negatives,
      )
  
      mul_value = precision * recall
      add_value = (tf.math.square(self.beta) * precision) + recall
      mean = tf.math.divide_no_nan(mul_value, add_value)
      f1_score = mean * (1 + tf.math.square(self.beta))
  
      if self.average == "weighted":
          weights = tf.math.divide_no_nan(
              self.weights_intermediate,
              tf.reduce_sum(self.weights_intermediate),
          )
          f1_score = tf.reduce_sum(f1_score * weights)
  
      elif self.average is not None:  # [micro, macro]
          f1_score = tf.reduce_mean(f1_score)
  
      return f1_score
  
file_path: addons/tensorflow_addons/metrics/f_scores.py
imports: import tensorflow
  from tensorflow.keras import backend
  from typeguard import typechecked
  from tensorflow_addons.utils.types import AcceptableDTypes, FloatTensorLike
  from typing import Optional
label_desc: Use image node_id 3 for calling the FBetaScore obj's underlying member method code with example usage: obj.result() and returns: f1_score