class_docstr: Computes Kappa score between two raters.
  
  The score lies in the range `[-1, 1]`. A score of -1 represents
  complete disagreement between two raters whereas a score of 1
  represents complete agreement between the two raters.
  A score of 0 means agreement by chance.
  
  Note: As of now, this implementation considers all labels
  while calculating the Cohen's Kappa score.
  
  Args:
      num_classes: Number of unique classes in your dataset.
      weightage: (optional) Weighting to be considered for calculating
          kappa statistics. A valid value is one of
          [None, 'linear', 'quadratic']. Defaults to `None`
      sparse_labels: (bool) Valid only for multi-class scenario.
          If True, ground truth labels are expected to be integers
          and not one-hot encoded.
      regression: (bool) If set, that means the problem is being treated
          as a regression problem where you are regressing the predictions.
          **Note:** If you are regressing for the values, the the output layer
          should contain a single unit.
      name: (optional) String name of the metric instance
      dtype: (optional) Data type of the metric result. Defaults to `None`.
  
  Raises:
      ValueError: If the value passed for `weightage` is invalid
      i.e. not any one of [None, 'linear', 'quadratic'].
  
  Usage:
  
  >>> y_true = np.array([4, 4, 3, 4, 2, 4, 1, 1], dtype=np.int32)
  >>> y_pred = np.array([4, 4, 3, 4, 4, 2, 1, 1], dtype=np.int32)
  >>> weights = np.array([1, 1, 2, 5, 10, 2, 3, 3], dtype=np.int32)
  >>> metric = tfa.metrics.CohenKappa(num_classes=5, sparse_labels=True)
  >>> metric.update_state(y_true , y_pred)
  <tf.Tensor: shape=(5, 5), dtype=float32, numpy=
   array([[0., 0., 0., 0., 0.],
          [0., 2., 0., 0., 0.],
          [0., 0., 0., 0., 1.],
          [0., 0., 0., 1., 0.],
          [0., 0., 1., 0., 3.]], dtype=float32)>
  >>> result = metric.result()
  >>> result.numpy()
  0.61904764
  >>> # To use this with weights, sample_weight argument can be used.
  >>> metric = tfa.metrics.CohenKappa(num_classes=5, sparse_labels=True)
  >>> metric.update_state(y_true , y_pred , sample_weight=weights)
  <tf.Tensor: shape=(5, 5), dtype=float32, numpy=
   array([[ 0.,  0.,  0.,  0.,  0.],
          [ 0.,  6.,  0.,  0.,  0.],
          [ 0.,  0.,  0.,  0., 10.],
          [ 0.,  0.,  0.,  2.,  0.],
          [ 0.,  0.,  2.,  0.,  7.]], dtype=float32)>
  >>> result = metric.result()
  >>> result.numpy()
   0.37209308
  
  Usage with `tf.keras` API:
  
  >>> inputs = tf.keras.Input(shape=(10,))
  >>> x = tf.keras.layers.Dense(10)(inputs)
  >>> outputs = tf.keras.layers.Dense(1)(x)
  >>> model = tf.keras.models.Model(inputs=inputs, outputs=outputs)
  >>> model.compile('sgd', loss='mse', metrics=[tfa.metrics.CohenKappa(num_classes=3, sparse_labels=True)])
class_docstr_tok: ["Computes","Kappa","score","between","two","raters",".","The","score","lies","in","the","range","`","[","-1",",","1","]","`",".","A","score","of","-1","represents","complete","disagreement","between","two","raters","whereas","a","score","of","1","represents","complete","agreement","between","the","two","raters",".","A","score","of","0","means","agreement","by","chance",".","Note",":","As","of","now",",","this","implementation","considers","all","labels","while","calculating","the","Cohen","'s","Kappa","score",".","Args",":","num_classes",":","Number","of","unique","classes","in","your","dataset",".","weightage",":","(","optional",")","Weighting","to","be","considered","for","calculating","kappa","statistics",".","A","valid","value","is","one","of","[","None",",","'linear","'",",","'quadratic","'","]",".","Defaults","to","`","None","`","sparse_labels",":","(","bool",")","Valid","only","for","multi-class","scenario",".","If","True",",","ground","truth","labels","are","expected","to","be","integers","and","not","one-hot","encoded",".","regression",":","(","bool",")","If","set",",","that","means","the","problem","is","being","treated","as","a","regression","problem","where","you","are","regressing","the","predictions",".","*","*","Note",":","*","*","If","you","are","regressing","for","the","values",",","the","the","output","layer","should","contain","a","single","unit",".","name",":","(","optional",")","String","name","of","the","metric","instance","dtype",":","(","optional",")","Data","type","of","the","metric","result",".","Defaults","to","`","None","`",".","Raises",":","ValueError",":","If","the","value","passed","for","`","weightage","`","is","invalid","i.e",".","not","any","one","of","[","None",",","'linear","'",",","'quadratic","'","]",".","Usage",":",">",">",">","y_true","=","np.array","(","[","4",",","4",",","3",",","4",",","2",",","4",",","1",",","1","]",",","dtype=np.int32",")",">",">",">","y_pred","=","np.array","(","[","4",",","4",",","3",",","4",",","4",",","2",",","1",",","1","]",",","dtype=np.int32",")",">",">",">","weights","=","np.array","(","[","1",",","1",",","2",",","5",",","10",",","2",",","3",",","3","]",",","dtype=np.int32",")",">",">",">","metric","=","tfa.metrics.CohenKappa","(","num_classes=5",",","sparse_labels=True",")",">",">",">","metric.update_state","(","y_true",",","y_pred",")","<","tf.Tensor",":","shape=","(","5",",","5",")",",","dtype=float32",",","numpy=","array","(","[","[","0.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","2.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","1",".","]",",","[","0.",",","0.",",","0.",",","1.",",","0",".","]",",","[","0.",",","0.",",","1.",",","0.",",","3",".","]","]",",","dtype=float32",")",">",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","0.61904764",">",">",">","#","To","use","this","with","weights",",","sample_weight","argument","can","be","used",".",">",">",">","metric","=","tfa.metrics.CohenKappa","(","num_classes=5",",","sparse_labels=True",")",">",">",">","metric.update_state","(","y_true",",","y_pred",",","sample_weight=weights",")","<","tf.Tensor",":","shape=","(","5",",","5",")",",","dtype=float32",",","numpy=","array","(","[","[","0.",",","0.",",","0.",",","0.",",","0",".","]",",","[","0.",",","6.",",","0.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","10",".","]",",","[","0.",",","0.",",","0.",",","2.",",","0",".","]",",","[","0.",",","0.",",","2.",",","0.",",","7",".","]","]",",","dtype=float32",")",">",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","0.37209308","Usage","with","`","tf.keras","`","API",":",">",">",">","inputs","=","tf.keras.Input","(","shape=","(","10",",",")",")",">",">",">","x","=","tf.keras.layers.Dense","(","10",")","(","inputs",")",">",">",">","outputs","=","tf.keras.layers.Dense","(","1",")","(","x",")",">",">",">","model","=","tf.keras.models.Model","(","inputs=inputs",",","outputs=outputs",")",">",">",">","model.compile","(","'sgd","'",",","loss='mse","'",",","metrics=","[","tfa.metrics.CohenKappa","(","num_classes=3",",","sparse_labels=True",")","]",")"]
code: def _update_binary_class_model(
      self, y_true, y_pred, sample_weight=None
  ):
      y_true = tf.cast(y_true, dtype=tf.int64)
      y_pred = tf.cast(y_pred, dtype=tf.float32)
      y_pred = tf.cast(y_pred > 0.5, dtype=tf.int64)
      return self._update_confusion_matrix(
          y_true, y_pred, sample_weight
      )
  
file_path: addons/tensorflow_addons/metrics/cohens_kappa.py
imports: import tensorflow
  import numpy
  import tensorflow.keras.backend
  from tensorflow.keras.metrics import Metric
  from tensorflow_addons.utils.types import AcceptableDTypes, FloatTensorLike
  from typeguard import typechecked
  from typing import Optional
label_desc: Use image node_id 3 for calling the CohenKappa obj's underlying member method code with example usage: obj._update_binary_class_model(y_true, y_pred, sample_weight) and returns: self