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

    https://github.com/apache/spark/pull/11621#discussion_r58467841
  
    --- Diff: python/pyspark/ml/regression.py ---
    @@ -151,6 +151,209 @@ def intercept(self):
             """
             return self._call_java("intercept")
     
    +    @property
    +    @since("2.0.0")
    +    def summary(self):
    +        """
    +        Gets summary (e.g. residuals, mse, r-squared ) of model on
    +        training set. An exception is thrown if
    +        `trainingSummary == None`.
    +        """
    +        java_lrt_summary = self._call_java("summary")
    +        return LinearRegressionTrainingSummary(java_lrt_summary)
    +
    +    @property
    +    @since("2.0.0")
    +    def hasSummary(self):
    +        """
    +        Indicates whether a training summary exists for this model
    +        instance.
    +        """
    +        return self._call_java("hasSummary")
    +
    +    @since("2.0.0")
    +    def evaluate(self, dataset):
    +        """
    +        Evaluates the model on a test dataset.
    +
    +        :param dataset:
    +          Test dataset to evaluate model on.
    +        """
    +        java_lr_summary = self._call_java("evaluate", dataset)
    +        return LinearRegressionSummary(java_lr_summary)
    +
    +
    +class LinearRegressionSummary(JavaCallable):
    +    """
    +    .. note:: Experimental
    +
    +    Linear regression results evaluated on a dataset.
    +
    +    .. versionadded:: 2.0.0
    +    """
    +
    +    @property
    +    @since("2.0.0")
    +    def predictions(self):
    +        """
    +        Dataframe outputted by the model's `transform` method.
    +        """
    +        return self._call_java("predictions")
    +
    +    @property
    +    @since("2.0.0")
    +    def predictionCol(self):
    +        """
    +        Field in "predictions" which gives the predicted value of
    +        the label at each instance.
    +        """
    +        return self._call_java("predictionCol")
    +
    +    @property
    +    @since("2.0.0")
    +    def labelCol(self):
    +        """
    +        Field in "predictions" which gives the true label of each
    +        instance.
    +        """
    +        return self._call_java("labelCol")
    +
    +    @property
    +    @since("2.0.0")
    +    def explainedVariance(self):
    +        """
    +        Returns the explained variance regression score.
    +        explainedVariance = 1 - variance(y - \hat{y}) / variance(y)
    +        Reference: http://en.wikipedia.org/wiki/Explained_variation
    +
    +        Note: This ignores instance weights (setting all to 1.0) from
    +        `LinearRegression.weightCol`. This will change in later Spark
    +        versions.
    +        """
    +        return self._call_java("explainedVariance")
    +
    +    @property
    +    @since("2.0.0")
    +    def meanAbsoluteError(self):
    +        """
    +        Returns the mean absolute error, which is a risk function
    +        corresponding to the expected value of the absolute error
    +        loss or l1-norm loss.
    +
    +        Note: This ignores instance weights (setting all to 1.0) from
    +        `LinearRegression.weightCol`. This will change in later Spark
    +        versions.
    +        """
    +        return self._call_java("meanAbsoluteError")
    +
    +    @property
    +    @since("2.0.0")
    +    def meanSquaredError(self):
    +        """
    +        Returns the mean squared error, which is a risk function
    +        corresponding to the expected value of the squared error
    +        loss or quadratic loss.
    +
    +        Note: This ignores instance weights (setting all to 1.0) from
    +        `LinearRegression.weightCol`. This will change in later Spark
    +        versions.
    +        """
    +        return self._call_java("meanSquaredError")
    +
    +    @property
    +    @since("2.0.0")
    +    def rootMeanSquaredError(self):
    +        """
    +        Returns the root mean squared error, which is defined as the
    +        square root of the mean squared error.
    +
    +        Note: This ignores instance weights (setting all to 1.0) from
    +        `LinearRegression.weightCol`. This will change in later Spark
    +        versions.
    +        """
    +        return self._call_java("rootMeanSquaredError")
    +
    +    @property
    +    @since("2.0.0")
    +    def r2(self):
    +        """
    +        Returns R^2^, the coefficient of determination.
    +        Reference: 
http://en.wikipedia.org/wiki/Coefficient_of_determination
    +
    +        Note: This ignores instance weights (setting all to 1.0) from
    +        `LinearRegression.weightCol`. This will change in later Spark
    +        versions.
    +        """
    +        return self._call_java("r2")
    +
    +    @property
    +    @since("2.0.0")
    +    def residuals(self):
    +        """
    +        Residuals (label - predicted value)
    +        """
    +        return self._call_java("residuals")
    +
    +    @property
    +    @since("2.0.0")
    +    def numInstances(self):
    +        """
    +        Number of instances in DataFrame predictions
    +        """
    +        return self._call_java("numInstances")
    +
    +    @property
    +    @since("2.0.0")
    +    def devianceResiduals(self):
    +        """
    +        The weighted residuals, the usual residuals rescaled by the
    +        square root of the instance weights.
    +        """
    +        return self._call_java("devianceResiduals")
    +
    +    @property
    +    @since("2.0.0")
    +    def coefficientStandardErrors(self):
    +        """
    +        Standard error of estimated coefficients and intercept.
    +        """
    +        return self._call_java("coefficientStandardErrors")
    +
    +    @property
    +    @since("2.0.0")
    +    def tValues(self):
    +        """
    +        T-statistic of estimated coefficients and intercept.
    +        """
    +        return self._call_java("tValues")
    +
    +    @property
    +    @since("2.0.0")
    +    def pValues(self):
    +        """
    +        Two-sided p-value of estimated coefficients and intercept.
    +        """
    +        return self._call_java("pValues")
    --- End diff --
    
    +1 for noting that they may not be available depending on the solver.  How 
about:
    ```
    This value is only available when using the "normal" solver.
    .. seealso:: :py:attr:`LinearRegression.solver`
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to