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

    https://github.com/apache/spark/pull/10274#discussion_r49822543
  
    --- 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 --
    
    Awesome! Great that you see the same result! For normal equation, will be 
nice to in R so we can have it in comment consistently. I did implement it once 
when I implemented the LBFGS version, let me try to find it.


---
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