class_docstr: Evaluator for regression.
  
  .. versionadded:: 1.4.0
  
  Parameters
  ----------
  predictionAndObservations : :py:class:`pyspark.RDD`
      an RDD of prediction, observation and optional weight.
  
  Examples
  --------
  >>> predictionAndObservations = sc.parallelize([
  ...     (2.5, 3.0), (0.0, -0.5), (2.0, 2.0), (8.0, 7.0)])
  >>> metrics = RegressionMetrics(predictionAndObservations)
  >>> metrics.explainedVariance
  8.859...
  >>> metrics.meanAbsoluteError
  0.5...
  >>> metrics.meanSquaredError
  0.37...
  >>> metrics.rootMeanSquaredError
  0.61...
  >>> metrics.r2
  0.94...
  >>> predictionAndObservationsWithOptWeight = sc.parallelize([
  ...     (2.5, 3.0, 0.5), (0.0, -0.5, 1.0), (2.0, 2.0, 0.3), (8.0, 7.0, 0.9)])
  >>> metrics = RegressionMetrics(predictionAndObservationsWithOptWeight)
  >>> metrics.rootMeanSquaredError
  0.68...
code: def __init__(
      self, predictionAndObservations: RDD[Tuple[float, float]]
  ):
      sc = predictionAndObservations.ctx
      sql_ctx = SQLContext.getOrCreate(sc)
      numCol = len(predictionAndObservations.first())
      schema = StructType(
          [
              StructField("prediction", DoubleType(), nullable=False),
              StructField("observation", DoubleType(), nullable=False),
          ]
      )
      if numCol == 3:
          schema.add("weight", DoubleType(), False)
      df = sql_ctx.createDataFrame(
          predictionAndObservations, schema=schema
      )
      assert sc._jvm is not None
      java_class = (
          sc._jvm.org.apache.spark.mllib.evaluation.RegressionMetrics
      )
      java_model = java_class(df._jdf)
      super(RegressionMetrics, self).__init__(java_model)
  
imports: from typing import Generic, List, Optional, Tuple, TypeVar, Union
  import sys
  from pyspark import since
  from pyspark.rdd import RDD
  from pyspark.mllib.common import JavaModelWrapper, callMLlibFunc
  from pyspark.mllib.linalg import Matrix
  from pyspark.sql import SQLContext
  from pyspark.sql.types import ArrayType, DoubleType, StructField, StructType
label_desc: Use image node_id 1 to create a new RegressionMetrics object from inherited base classes: JavaModelWrapper with example: obj = RegressionMetrics(predictionAndObservations)