You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/06/10 20:05:12 UTC

[GitHub] [spark] srowen commented on a change in pull request #28772: [SPARK-31944] Add instance weight support in LinearRegressionSummary

srowen commented on a change in pull request #28772:
URL: https://github.com/apache/spark/pull/28772#discussion_r438377687



##########
File path: mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala
##########
@@ -961,51 +962,48 @@ class LinearRegressionSummary private[regression] (
     private val privateModel: LinearRegressionModel,
     private val diagInvAtWA: Array[Double]) extends Serializable {
 
-  @transient private val metrics = new RegressionMetrics(
-    predictions
-      .select(col(predictionCol), col(labelCol).cast(DoubleType))
-      .rdd
-      .map { case Row(pred: Double, label: Double) => (pred, label) },
-    !privateModel.getFitIntercept)
+  @transient private val metrics = {
+    val weightCol =
+      if (!privateModel.isDefined(privateModel.weightCol) || privateModel.getWeightCol.isEmpty) {
+        lit(1.0)
+      } else {
+        checkNonNegativeWeight(col(privateModel.getWeightCol).cast(DoubleType))

Review comment:
       Is this check needed -- would the regression implementation have already checked it? OK if not.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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