Skip to content

Commit

Permalink
rename featureunion in ppls
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Mar 26, 2024
1 parent 11a22ce commit 0804b44
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# mlr3pipelines 0.5.0-9000

* Changed the ID of `PipeOpFeatureUnion` used in `ppl("robustify")` and `ppl("stacking")`
* Feature: The `$add_pipeop()` method got an argument `clone` (old behaviour `TRUE` by default)
* Bugfix: `PipeOpFeatureUnion` in some rare cases dropped variables called `"x"`
* Compatibility with upcoming paradox release
Expand Down
2 changes: 1 addition & 1 deletion R/pipeline_robustify.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pipeline_robustify = function(task = NULL, learner = NULL,
imputing,
po("missind", affect_columns = selector_type(c("numeric", "integer", "logical")), type = if (missind_numeric) "numeric" else "factor")
)),
if (has_numbers || has_logicals) po("featureunion"),
if (has_numbers || has_logicals) po("featureunion", id = "featureunion_robustify"),
if (has_factorials) po("imputeoor")
)

Expand Down
2 changes: 1 addition & 1 deletion R/pipeline_stacking.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pipeline_stacking = function(base_learners, super_learner, method = "cv", folds
if (use_features) base_learners_cv = c(base_learners_cv, po("nop"))

gunion(base_learners_cv, in_place = TRUE) %>>!%
po("featureunion") %>>!%
po("featureunion", id = "featureunion_stacking") %>>!%
super_learner
}

Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test_ppl.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,19 @@ test_that("mlr_pipeops multi-access works", {
expect_equal(ppls(), mlr_graphs)

})

test_that("mlr3book authors don't sleepwalk through life", {

tasks = tsks(c("breast_cancer", "sonar"))


glrn_stack = as_learner(ppl("robustify") %>>% ppl("stacking",
lrns(c("classif.rpart", "classif.debug")),
lrn("classif.log_reg")
))
glrn_stack$id = "Stack"

learners = c(glrn_stack)
bmr = benchmark(benchmark_grid(tasks, learners, rsmp("cv", folds = 3)))

})

0 comments on commit 0804b44

Please sign in to comment.