You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by yanboliang <gi...@git.apache.org> on 2017/01/09 14:09:03 UTC

[GitHub] spark pull request #16511: [SPARK-19133][SPARKR][ML] fix glm for Gamma, clar...

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

    https://github.com/apache/spark/pull/16511#discussion_r95160553
  
    --- Diff: R/pkg/inst/tests/testthat/test_mllib_regression.R ---
    @@ -61,14 +61,22 @@ test_that("spark.glm and predict", {
     
       # poisson family
       model <- spark.glm(training, Sepal_Width ~ Sepal_Length + Species,
    -  family = poisson(link = identity))
    +                     family = poisson(link = identity))
       prediction <- predict(model, training)
       expect_equal(typeof(take(select(prediction, "prediction"), 1)$prediction), "double")
       vals <- collect(select(prediction, "prediction"))
       rVals <- suppressWarnings(predict(glm(Sepal.Width ~ Sepal.Length + Species,
    -  data = iris, family = poisson(link = identity)), iris))
    +                                        data = iris, family = poisson(link = identity)), iris))
       expect_true(all(abs(rVals - vals) < 1e-6), rVals - vals)
     
    +  # Gamma family
    +  x <- runif(100, -1, 1)
    +  y <- rgamma(100, rate = 10 / exp(0.5 + 1.2 * x), shape = 10)
    +  df <- as.DataFrame(as.data.frame(list(x = x, y = y)))
    +  model <- glm(y ~ x, family = Gamma, df)
    --- End diff --
    
    I'd prefer to use ```spark.glm``` here, since the title of this test is: ```spark.glm and predict```(see L52). We have separate tests for R-compliant method ```glm```, but it's not necessary to duplicate all tests.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org