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

    https://github.com/apache/spark/pull/10702#discussion_r51505471
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/regression/LinearRegressionSuite.scala 
---
    @@ -558,6 +575,47 @@ class LinearRegressionSuite
         }
       }
     
    +  test("linear regression model with constant label") {
    +    /*
    +       R code:
    +       for (formula in c(b.const ~ . -1, b.const ~ .)) {
    +         model <- lm(formula, data=df.const.label, 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))
    +
    +    Seq("auto", "l-bfgs", "normal").foreach { solver =>
    +      var idx = 0
    +      for (fitIntercept <- Seq(false, true)) {
    +        val model = new LinearRegression()
    +          .setFitIntercept(fitIntercept)
    +          .setWeightCol("weight")
    +          .setSolver(solver)
    +          .fit(datasetWithWeightConstantLabel)
    +        val actual = Vectors.dense(model.intercept, model.coefficients(0), 
model.coefficients(1))
    +        assert(actual ~== expected(idx) absTol 1e-4)
    +        idx += 1
    --- End diff --
    
    I've added tests as suggested.


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