Github user dbtsai commented on a diff in the pull request: https://github.com/apache/spark/pull/10274#discussion_r51059677 --- 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 -- Sorry for getting you back so late. The difference is due to that `glmnet` always standardizes labels even `standardization == false`. `standardization == false` is turning off the standardization on features. As a result, at least in `glmnet`, when `ystd == 0.0`, the training is not valid.
--- 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