class_docstr: Computes the Matthews Correlation Coefficient.
  
  The statistic is also known as the phi coefficient.
  The Matthews correlation coefficient (MCC) is used in
  machine learning as a measure of the quality of binary
  and multiclass classifications. It takes into account
  true and false positives and negatives and is generally
  regarded as a balanced measure which can be used even
  if the classes are of very different sizes. The correlation
  coefficient value of MCC is between -1 and +1. A
  coefficient of +1 represents a perfect prediction,
  0 an average random prediction and -1 an inverse
  prediction. The statistic is also known as
  the phi coefficient.
  
  MCC = (TP * TN - FP * FN) /
        ((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN))^(1/2)
  
  Args:
      num_classes : Number of unique classes in the dataset.
      name: (Optional) String name of the metric instance.
      dtype: (Optional) Data type of the metric result.
  
  Usage:
  
  >>> y_true = np.array([[0.0, 1.0], [0.0, 1.0], [0.0, 1.0], [1.0, 0.0]], dtype=np.float32)
  >>> y_pred = np.array([[0.0, 1.0], [1.0, 0.0], [0.0, 1.0], [0.0, 1.0]], dtype=np.float32)
  >>> metric = tfa.metrics.MatthewsCorrelationCoefficient(num_classes=2)
  >>> metric.update_state(y_true, y_pred)
  >>> result = metric.result()
  >>> result.numpy()
  -0.33333334
class_docstr_tok: ["Computes","the","Matthews","Correlation","Coefficient",".","The","statistic","is","also","known","as","the","phi","coefficient",".","The","Matthews","correlation","coefficient","(","MCC",")","is","used","in","machine","learning","as","a","measure","of","the","quality","of","binary","and","multiclass","classifications",".","It","takes","into","account","true","and","false","positives","and","negatives","and","is","generally","regarded","as","a","balanced","measure","which","can","be","used","even","if","the","classes","are","of","very","different","sizes",".","The","correlation","coefficient","value","of","MCC","is","between","-1","and","+1",".","A","coefficient","of","+1","represents","a","perfect","prediction",",","0","an","average","random","prediction","and","-1","an","inverse","prediction",".","The","statistic","is","also","known","as","the","phi","coefficient",".","MCC","=","(","TP","*","TN","-","FP","*","FN",")","\/","(","(","TP","+","FP",")","*","(","TP","+","FN",")","*","(","TN","+","FP",")","*","(","TN","+","FN",")",")","^","(","1\/2",")","Args",":","num_classes",":","Number","of","unique","classes","in","the","dataset",".","name",":","(","Optional",")","String","name","of","the","metric","instance",".","dtype",":","(","Optional",")","Data","type","of","the","metric","result",".","Usage",":",">",">",">","y_true","=","np.array","(","[","[","0.0",",","1.0","]",",","[","0.0",",","1.0","]",",","[","0.0",",","1.0","]",",","[","1.0",",","0.0","]","]",",","dtype=np.float32",")",">",">",">","y_pred","=","np.array","(","[","[","0.0",",","1.0","]",",","[","1.0",",","0.0","]",",","[","0.0",",","1.0","]",",","[","0.0",",","1.0","]","]",",","dtype=np.float32",")",">",">",">","metric","=","tfa.metrics.MatthewsCorrelationCoefficient","(","num_classes=2",")",">",">",">","metric.update_state","(","y_true",",","y_pred",")",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","-0.33333334"]
code: def result(self):
      true_sum = tf.reduce_sum(self.conf_mtx, axis=1)
      pred_sum = tf.reduce_sum(self.conf_mtx, axis=0)
      num_correct = tf.linalg.trace(self.conf_mtx)
      num_samples = tf.reduce_sum(pred_sum)
  
      # covariance true-pred
      cov_ytyp = num_correct * num_samples - tf.tensordot(
          true_sum, pred_sum, axes=1
      )
      # covariance pred-pred
      cov_ypyp = num_samples**2 - tf.tensordot(
          pred_sum, pred_sum, axes=1
      )
      # covariance true-true
      cov_ytyt = num_samples**2 - tf.tensordot(
          true_sum, true_sum, axes=1
      )
  
      mcc = cov_ytyp / tf.math.sqrt(cov_ytyt * cov_ypyp)
  
      if tf.math.is_nan(mcc):
          mcc = tf.constant(0, dtype=self.dtype)
  
      return mcc
  
file_path: addons/tensorflow_addons/metrics/matthews_correlation_coefficient.py
imports: import numpy
  import tensorflow
  from tensorflow.keras import backend
  from tensorflow_addons.utils.types import AcceptableDTypes, FloatTensorLike
  from typeguard import typechecked
label_desc: Use image node_id 3 for calling the MatthewsCorrelationCoefficient obj's underlying member method code with example usage: obj.result() and returns: mcc