Skip to content

Commit 7d18533

Browse files
authored
Merge pull request #765 from mlr-org/rename_fu_in_ppl
rename featureunion in ppls
2 parents 5dc84f6 + 47e3ee5 commit 7d18533

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# mlr3pipelines 0.5.0-9000
22

3+
* Changed the ID of `PipeOpFeatureUnion` used in `ppl("robustify")` and `ppl("stacking")`.
34
* `pipeline_bagging()` gets the `replace` argument (old behaviour `FALSE` by default).
45
* Feature: The `$add_pipeop()` method got an argument `clone` (old behaviour `TRUE` by default).
56
* Bugfix: `PipeOpFeatureUnion` in some rare cases dropped variables called `"x"`.

R/pipeline_robustify.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pipeline_robustify = function(task = NULL, learner = NULL,
170170
imputing,
171171
po("missind", affect_columns = selector_type(c("numeric", "integer", "logical")), type = if (missind_numeric) "numeric" else "factor")
172172
)),
173-
if (has_numbers || has_logicals) po("featureunion"),
173+
if (has_numbers || has_logicals) po("featureunion", id = "featureunion_robustify"),
174174
if (has_factorials) po("imputeoor")
175175
)
176176

R/pipeline_stacking.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pipeline_stacking = function(base_learners, super_learner, method = "cv", folds
5353
if (use_features) base_learners_cv = c(base_learners_cv, po("nop"))
5454

5555
gunion(base_learners_cv, in_place = TRUE) %>>!%
56-
po("featureunion") %>>!%
56+
po("featureunion", id = "featureunion_stacking") %>>!%
5757
super_learner
5858
}
5959

tests/testthat/test_mlr_graphs_stacking.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test_that("Stacking Pipeline", {
1010
# default
1111
graph_stack = pipeline_stacking(base_learners, super_learner)
1212
expect_graph(graph_stack)
13-
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "nop", "featureunion", "super.rpart"))
13+
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "nop", "featureunion_stacking", "super.rpart"))
1414
graph_learner = as_learner(graph_stack)
1515
graph_learner$train(tsk("iris"))
1616
expect_class(graph_learner$model$super.rpart$model, "rpart")
@@ -19,7 +19,7 @@ test_that("Stacking Pipeline", {
1919
# no nop
2020
graph_stack = pipeline_stacking(base_learners, super_learner, use_features = FALSE)
2121
expect_graph(graph_stack)
22-
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "featureunion", "super.rpart"))
22+
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "featureunion_stacking", "super.rpart"))
2323
graph_learner = as_learner(graph_stack)
2424
graph_learner$train(tsk("iris"))
2525
expect_class(graph_learner$model$super.rpart$model, "rpart")
@@ -28,7 +28,7 @@ test_that("Stacking Pipeline", {
2828
# folds
2929
graph_stack = pipeline_stacking(base_learners, super_learner, folds = 5)
3030
expect_graph(graph_stack)
31-
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "nop", "featureunion", "super.rpart"))
31+
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "nop", "featureunion_stacking", "super.rpart"))
3232
graph_learner = as_learner(graph_stack)
3333
graph_learner$train(tsk("iris"))
3434
expect_equal(graph_learner$graph$pipeops$base.rpart$param_set$values$resampling.folds, 5)
@@ -38,7 +38,7 @@ test_that("Stacking Pipeline", {
3838
# insample
3939
graph_stack = pipeline_stacking(base_learners, super_learner, method = "insample")
4040
expect_graph(graph_stack)
41-
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "nop", "featureunion", "super.rpart"))
41+
expect_names(graph_stack$ids(), identical.to = c("base.rpart", "nop", "featureunion_stacking", "super.rpart"))
4242
graph_learner = as_learner(graph_stack)
4343
graph_learner$train(tsk("iris"))
4444
expect_equal(graph_learner$graph$pipeops$base.rpart$param_set$values$resampling.method, "insample")

tests/testthat/test_ppl.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,18 @@ test_that("mlr_pipeops multi-access works", {
5757
expect_equal(ppls(), mlr_graphs)
5858

5959
})
60+
61+
test_that("mlr3book authors don't sleepwalk through life", {
62+
63+
tasks = tsks(c("breast_cancer", "sonar"))
64+
65+
glrn_stack = as_learner(ppl("robustify") %>>% ppl("stacking",
66+
lrns(c("classif.rpart", "classif.debug")),
67+
lrn("classif.rpart", id = "classif.rpart2")
68+
))
69+
glrn_stack$id = "Stack"
70+
71+
learners = c(glrn_stack)
72+
bmr = benchmark(benchmark_grid(tasks, learners, rsmp("cv", folds = 2)))
73+
74+
})

0 commit comments

Comments
 (0)