data(audit) test_that("pmml.ada error when object is not ada", { a <- "foo" expect_error(pmml.ada(a), "Not a legitimate ada object") }) test_that("Elements and attributes are correct", { skip_if_not_installed("ada") library(ada) fit <- ada(Adjusted ~ Employment + Education + Hours + Income, iter = 3, audit) fit_pmml <- pmml(fit) # Test miningModel attributes expect_equal(xmlGetAttr(fit_pmml[[3]], name = "modelName"), "AdaBoost_Model") expect_equal(xmlGetAttr(fit_pmml[[3]], name = "functionName"), "regression") expect_equal(xmlGetAttr(fit_pmml[[3]], name = "algorithmName"), "ADA_BOOST") # Test Output node expect_equal(toString(fit_pmml[[3]][[2]][[1]]), "") expect_equal(xmlGetAttr(fit_pmml[[3]][[2]][[2]], name = "name"), "boostValue") expect_equal(xmlGetAttr(fit_pmml[[3]][[2]][[2]], name = "feature"), "transformedValue") expect_equal(xmlGetAttr(fit_pmml[[3]][[2]][[2]], name = "dataType"), "double") expect_equal(xmlGetAttr(fit_pmml[[3]][[2]][[2]], name = "optype"), "continuous") expect_equal(toString(fit_pmml[[3]][[2]][[3]]), "\n \n \n \n 0.0\n \n 0\n 1\n \n") expect_equal(toString(fit_pmml[[3]][[2]][[4]]), "\n \n 1.0\n \n 1.0\n \n \n 2.0\n \n \n \n \n \n") expect_equal(toString(fit_pmml[[3]][[2]][[5]]), "\n \n 1.0\n \n \n") expect_error(toString(fit_pmml[[3]][[2]][[6]])) # Test Segmentation node attribute expect_equal(xmlGetAttr(fit_pmml[[3]][[4]], name = "multipleModelMethod"), "weightedAverage") })