context("mlr_learners_regr_rpart")
test_that("autotest", {
learner = lrn("regr.rpart")
expect_learner(learner)
result = run_autotest(learner)
expect_true(result, info = result$error)
})
test_that("variable importance", {
task = TaskRegr$new("foo", as_data_backend(cbind(iris, data.frame(unimportant = runif(150)))), target = "Sepal.Length")
learner = lrn("regr.rpart")
learner$train(task)
imp = learner$importance()
expect_numeric(imp, min.len = 1L, any.missing = FALSE)
expect_names(names(imp), subset.of = task$feature_names)
expect_false(is.unsorted(rev(imp)))
})
test_that("selected_features", {
task = TaskRegr$new("foo", as_data_backend(cbind(iris, data.frame(unimportant = runif(150)))), target = "Sepal.Length")
learner = lrn("regr.rpart", maxdepth = 2)
sf = learner$train(task)$selected_features()
expect_subset(sf, task$feature_names, empty.ok = FALSE)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.