From 0583ecda1b63a7e3f126c3276059e4f99548a741 Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Mon, 22 Aug 2016 12:27:33 -0700 Subject: [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 Closes #14735 from felixcheung/rmllibutil. --- R/pkg/inst/tests/testthat/test_mllib.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'R/pkg/inst/tests/testthat/test_mllib.R') 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) }) -- cgit v1.2.3