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

    https://github.com/apache/spark/pull/10702#discussion_r51064724
  
    --- 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
    +      }
    +    }
    +  }
    +
    +  test("regularized linear regression through origin with constant label") 
{
    +    // The problem is ill-defined if fitIntercept=false, regParam is 
non-zero and \
    --- End diff --
    
    Remove `\` in the end of line.


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