Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/9561#discussion_r44258052
--- Diff: R/pkg/inst/tests/test_mllib.R ---
@@ -71,12 +71,23 @@ test_that("feature interaction vs native glm", {
test_that("summary coefficients match with native glm", {
training <- createDataFrame(sqlContext, iris)
- stats <- summary(glm(Sepal_Width ~ Sepal_Length + Species, data =
training, solver = "l-bfgs"))
- coefs <- as.vector(stats$coefficients)
+ stats <- summary(glm(Sepal_Width ~ Sepal_Length + Species, data =
training, solver = "normal"))
+ coefs <- unlist(stats$Coefficients)
+ devianceResiduals <- unlist(stats$DevianceResiduals)
+
rCoefs <- as.vector(coef(glm(Sepal.Width ~ Sepal.Length + Species, data
= iris)))
- expect_true(all(abs(rCoefs - coefs) < 1e-6))
+ rStdError <- c(0.23536, 0.04630, 0.07207, 0.09331)
+ rTValue <- c(7.123, 7.557, -13.644, -10.798)
+ rPValue <- c(0.0, 0.0, 0.0, 0.0)
+ rDevianceResiduals <- c(-0.95096, 0.72918)
+
+ expect_true(all(abs(rCoefs - coefs[1:4]) < 1e-6))
+ expect_true(all(abs(rStdError - coefs[5:8]) < 1e-5))
+ expect_true(all(abs(rTValue - coefs[9:12]) < 1e-3))
+ expect_true(all(abs(rPValue - coefs[13:16]) < 1e-6))
--- End diff --
It's better to get R ```summary``` in this context and compare it with
SparkR::glm ```summary``` output. But we hit
[SPARK-11587](https://issues.apache.org/jira/browse/SPARK-11587) when calling R
```summary```, so I use the workaround to test ```summary``` output.
---
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]