class_docstr: Compute R^2 score.
  
  This is also called the [coefficient of determination
  ](https://en.wikipedia.org/wiki/Coefficient_of_determination).
  It tells how close are data to the fitted regression line.
  
  - Highest score can be 1.0 and it indicates that the predictors
      perfectly accounts for variation in the target.
  - Score 0.0 indicates that the predictors do not
      account for variation in the target.
  - It can also be negative if the model is worse.
  
  The sample weighting for this metric implementation mimics the
  behaviour of the [scikit-learn implementation
  ](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.r2_score.html)
  of the same metric.
  
  Can also calculate the Adjusted R2 Score.
  
  Args:
      multioutput: `string`, the reduce method for scores.
          Should be one of `["raw_values", "uniform_average", "variance_weighted"]`.
      name: (Optional) string name of the metric instance.
      dtype: (Optional) data type of the metric result.
      num_regressors: (Optional) Number of indepedent regressors used (Adjusted R2).
          Defaults to zero(standard R2 score).
  
  Usage:
  
  >>> y_true = np.array([1, 4, 3], dtype=np.float32)
  >>> y_pred = np.array([2, 4, 4], dtype=np.float32)
  >>> metric = tfa.metrics.r_square.RSquare()
  >>> metric.update_state(y_true, y_pred)
  >>> result = metric.result()
  >>> result.numpy()
  0.57142854
class_docstr_tok: ["Compute","R^2","score",".","This","is","also","called","the","[","coefficient","of","determination","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Coefficient_of_determination",")",".","It","tells","how","close","are","data","to","the","fitted","regression","line",".","-","Highest","score","can","be","1.0","and","it","indicates","that","the","predictors","perfectly","accounts","for","variation","in","the","target",".","-","Score","0.0","indicates","that","the","predictors","do","not","account","for","variation","in","the","target",".","-","It","can","also","be","negative","if","the","model","is","worse",".","The","sample","weighting","for","this","metric","implementation","mimics","the","behaviour","of","the","[","scikit-learn","implementation","]","(","https",":","\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.metrics.r2_score.html",")","of","the","same","metric",".","Can","also","calculate","the","Adjusted","R2","Score",".","Args",":","multioutput",":","`","string","`",",","the","reduce","method","for","scores",".","Should","be","one","of","`","[","``","raw_values","''",",","``","uniform_average","''",",","``","variance_weighted","''","]","`",".","name",":","(","Optional",")","string","name","of","the","metric","instance",".","dtype",":","(","Optional",")","data","type","of","the","metric","result",".","num_regressors",":","(","Optional",")","Number","of","indepedent","regressors","used","(","Adjusted","R2",")",".","Defaults","to","zero","(","standard","R2","score",")",".","Usage",":",">",">",">","y_true","=","np.array","(","[","1",",","4",",","3","]",",","dtype=np.float32",")",">",">",">","y_pred","=","np.array","(","[","2",",","4",",","4","]",",","dtype=np.float32",")",">",">",">","metric","=","tfa.metrics.r_square.RSquare","(",")",">",">",">","metric.update_state","(","y_true",",","y_pred",")",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","0.57142854"]
code: def __init__(
      self,
      name: str = "r_square",
      dtype: AcceptableDTypes = None,
      multioutput: str = "uniform_average",
      num_regressors: tf.int32 = 0,
      **kwargs,
  ):
      super().__init__(name=name, dtype=dtype, **kwargs)
  
      if "y_shape" in kwargs:
          warnings.warn(
              "y_shape has been removed, because it's automatically derived,"
              "and will be deprecated in Addons 0.18.",
              DeprecationWarning,
          )
  
      if multioutput not in _VALID_MULTIOUTPUT:
          raise ValueError(
              "The multioutput argument must be one of {}, but was: {}".format(
                  _VALID_MULTIOUTPUT, multioutput
              )
          )
      self.multioutput = multioutput
      self.num_regressors = num_regressors
      self.num_samples = self.add_weight(
          name="num_samples", dtype=tf.int32
      )
  
file_path: addons/tensorflow_addons/metrics/r_square.py
imports: import warnings
  import numpy
  import tensorflow
  from tensorflow.keras import backend
  from tensorflow.keras.metrics import Metric
  from tensorflow.python.ops import weights_broadcast_ops
  from typeguard import typechecked
  from tensorflow_addons.utils.types import AcceptableDTypes
label_desc: Use image node_id 1 to create a new RSquare object from inherited base classes: Metric with example: obj = RSquare(name, dtype, multioutput, num_regressors)