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

    https://github.com/apache/spark/pull/15683#discussion_r87609107
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/regression/GeneralizedLinearRegressionSuite.scala
 ---
    @@ -453,6 +464,56 @@ class GeneralizedLinearRegressionSuite
         }
       }
     
    +  test("generalized linear regression: poisson family against glm (with 
zero values)") {
    +    /*
    +       R code:
    +       f1 <- data$V1 ~ data$V2 + data$V3 - 1
    +       f2 <- data$V1 ~ data$V2 + data$V3
    +
    +       data <- read.csv("path", header=FALSE)
    +       for (formula in c(f1, f2)) {
    +         model <- glm(formula, family="poisson", data=data)
    +         print(as.vector(coef(model)))
    +       }
    +       [1]  0.4272661 -0.1565423
    +       [1] -3.6911354  0.6214301  0.1295814
    +
    +     */
    +    val expected = Seq(
    +      Vectors.dense(0.0, 0.4272661, -0.1565423),
    +      Vectors.dense(-3.6911354, 0.6214301, 0.1295814))
    +
    +    import GeneralizedLinearRegression._
    +
    +    var idx = 0
    +    val link = "log"
    +    val dataset = datasetPoissonLogWithZero
    +    for (fitIntercept <- Seq(false, true)) {
    +      val trainer = new 
GeneralizedLinearRegression().setFamily("poisson").setLink(link)
    +        
.setFitIntercept(fitIntercept).setLinkPredictionCol("linkPrediction")
    +      val model = trainer.fit(dataset)
    +      val actual = Vectors.dense(model.intercept, model.coefficients(0), 
model.coefficients(1))
    +      assert(actual ~= expected(idx) absTol 1e-4, "Model mismatch: GLM 
with poisson family, " +
    +        s"$link link and fitIntercept = $fitIntercept (with zero values).")
    +
    +      val familyLink = new FamilyAndLink(Poisson, Link.fromName(link))
    +      model.transform(dataset).select("features", "prediction", 
"linkPrediction").collect()
    --- End diff --
    
    I don't see any reason to test the predictions here. Checking the 
coefficients should be enough, since we test for correctness in other places.


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