Github user yanboliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5941#discussion_r29867547
  
    --- Diff: python/pyspark/mllib/evaluation.py ---
    @@ -67,6 +67,73 @@ def unpersist(self):
             self.call("unpersist")
     
     
    +class RegressionMetrics(JavaModelWrapper):
    +    """
    +    Evaluator for regression.
    +
    +    >>> predictionAndObservations = sc.parallelize([
    +    ...     (2.5, 3.0), (0.0, -0.5), (2.0, 2.0), (8.0, 7.0)])
    +    >>> metrics = RegressionMetrics(predictionAndObservations)
    +    >>> metrics.explainedVariance()
    +    0.95...
    +    >>> metrics.meanAbsoluteError()
    +    0.5...
    +    >>> metrics.meanSquaredError()
    +    0.37...
    +    >>> metrics.rootMeanSquaredError()
    +    0.61...
    +    >>> metrics.r2()
    +    0.94...
    +    """
    +
    +    def __init__(self, predictionAndObservations):
    +        """
    +        :param predictionAndObservations: an RDD of (prediction, 
observation) pairs.
    +        """
    +        sc = predictionAndObservations.ctx
    +        sql_ctx = SQLContext(sc)
    +        df = sql_ctx.createDataFrame(predictionAndObservations, 
schema=StructType([
    +            StructField("prediction", DoubleType(), nullable=False),
    +            StructField("observation", DoubleType(), nullable=False)]))
    +        java_class = 
sc._jvm.org.apache.spark.mllib.evaluation.RegressionMetrics
    +        java_model = java_class(df._jdf)
    +        super(RegressionMetrics, self).__init__(java_model)
    +
    +    def explainedVariance(self):
    --- End diff --
    
    Yes, I agree. I will do it for both.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to