aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/testthat/test_mllib.R
diff options
context:
space:
mode:
authorFelix Cheung <felixcheung_m@hotmail.com>2016-08-22 12:27:33 -0700
committerFelix Cheung <felixcheung@apache.org>2016-08-22 12:27:33 -0700
commit0583ecda1b63a7e3f126c3276059e4f99548a741 (patch)
treed717ccb43a7463a66094485a0adff483e6562fb8 /R/pkg/inst/tests/testthat/test_mllib.R
parent342278c09cf6e79ed4f63422988a6bbd1e7d8a91 (diff)
downloadspark-0583ecda1b63a7e3f126c3276059e4f99548a741.tar.gz
spark-0583ecda1b63a7e3f126c3276059e4f99548a741.tar.bz2
spark-0583ecda1b63a7e3f126c3276059e4f99548a741.zip
[SPARK-17173][SPARKR] R MLlib refactor, cleanup, reformat, fix deprecation in test
## What changes were proposed in this pull request? refactor, cleanup, reformat, fix deprecation in test ## How was this patch tested? unit tests, manual tests Author: Felix Cheung <felixcheung_m@hotmail.com> Closes #14735 from felixcheung/rmllibutil.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_mllib.R')
-rw-r--r--R/pkg/inst/tests/testthat/test_mllib.R10
1 files changed, 7 insertions, 3 deletions
diff --git a/R/pkg/inst/tests/testthat/test_mllib.R b/R/pkg/inst/tests/testthat/test_mllib.R
index d15c2393b9..de9bd48662 100644
--- a/R/pkg/inst/tests/testthat/test_mllib.R
+++ b/R/pkg/inst/tests/testthat/test_mllib.R
@@ -95,6 +95,10 @@ test_that("spark.glm summary", {
expect_equal(stats$df.residual, rStats$df.residual)
expect_equal(stats$aic, rStats$aic)
+ out <- capture.output(print(stats))
+ expect_match(out[2], "Deviance Residuals:")
+ expect_true(any(grepl("AIC: 59.22", out)))
+
# binomial family
df <- suppressWarnings(createDataFrame(iris))
training <- df[df$Species %in% c("versicolor", "virginica"), ]
@@ -409,7 +413,7 @@ test_that("spark.naiveBayes", {
# Test e1071::naiveBayes
if (requireNamespace("e1071", quietly = TRUE)) {
- expect_that(m <- e1071::naiveBayes(Survived ~ ., data = t1), not(throws_error()))
+ expect_error(m <- e1071::naiveBayes(Survived ~ ., data = t1), NA)
expect_equal(as.character(predict(m, t1[1, ])), "Yes")
}
})
@@ -487,7 +491,7 @@ test_that("spark.isotonicRegression", {
weightCol = "weight")
# only allow one variable on the right hand side of the formula
expect_error(model2 <- spark.isoreg(df, ~., isotonic = FALSE))
- result <- summary(model, df)
+ result <- summary(model)
expect_equal(result$predictions, list(7, 5, 4, 4, 1))
# Test model prediction
@@ -503,7 +507,7 @@ test_that("spark.isotonicRegression", {
expect_error(write.ml(model, modelPath))
write.ml(model, modelPath, overwrite = TRUE)
model2 <- read.ml(modelPath)
- expect_equal(result, summary(model2, df))
+ expect_equal(result, summary(model2))
unlink(modelPath)
})