Github user dbtsai commented on a diff in the pull request: https://github.com/apache/spark/pull/10274#discussion_r49400106 --- Diff: mllib/src/test/scala/org/apache/spark/ml/optim/WeightedLeastSquaresSuite.scala --- @@ -74,6 +89,35 @@ class WeightedLeastSquaresSuite extends SparkFunSuite with MLlibTestSparkContext } } + test("WLS against lm when label is constant") { + /* + R code: + # here b is constant + df <- as.data.frame(cbind(A, b)) + for (formula in c(b ~ . -1, b ~ .)) { + model <- lm(formula, data=df, weights=w) + print(as.vector(coef(model))) + } + + [1] -9.221298 3.394343 + [1] 17 0 0 + */ + + val expected = Seq( + Vectors.dense(0.0, -9.221298, 3.394343), + Vectors.dense(17.0, 0.0, 0.0)) + + var idx = 0 + for (fitIntercept <- Seq(false, true)) { + val wls = new WeightedLeastSquares( + fitIntercept, regParam = 0.0, standardizeFeatures = false, standardizeLabel = true) + .fit(instancesConstLabel) --- End diff -- Added `standardizeLabel = false` with non-zero `regParam` with analytic normal equation solution. Added failure test of `standardizeLabel = true`, `regParam != 0` and `yStd == 0.0`.
--- 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