Skip to content

Commit 6d851c6

Browse files
committed
rename inner to internal
1 parent 5556ec2 commit 6d851c6

File tree

11 files changed

+74
-74
lines changed

11 files changed

+74
-74
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ S3method(as_pipeop,Filter)
1111
S3method(as_pipeop,Learner)
1212
S3method(as_pipeop,PipeOp)
1313
S3method(as_pipeop,default)
14-
S3method(disable_inner_tuning,GraphLearner)
14+
S3method(disable_internal_tuning,GraphLearner)
1515
S3method(po,"NULL")
1616
S3method(po,Filter)
1717
S3method(po,Learner)

R/GraphLearner.R

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
#' contain the model. Use `graph_model` to access the trained [`Graph`] after `$train()`. Read-only.
4848
#' * `graph_model` :: [`Learner`][mlr3::Learner]\cr
4949
#' [`Graph`] that is being wrapped. This [`Graph`] contains a trained state after `$train()`. Read-only.
50-
#' * `inner_tuned_values` :: named `list()` or `NULL`\cr
51-
#' The inner tuned parameter values.
52-
#' `NULL` is returned if the learner is not trained or none of the wrapped learners supports inner tuning.
53-
#' * `inner_valid_scores` :: named `list()` or `NULL`\cr
54-
#' The inner tuned parameter values.
50+
#' * `internal_tuned_values` :: named `list()` or `NULL`\cr
51+
#' The internal tuned parameter values.
52+
#' `NULL` is returned if the learner is not trained or none of the wrapped learners supports internal tuning.
53+
#' * `internal_valid_scores` :: named `list()` or `NULL`\cr
54+
#' The internal tuned parameter values.
5555
#' `NULL` is returned if the learner is not trained or none of the wrapped learners supports internal validation.
56-
#' * `validate` :: `numeric(1)`, `"inner_valid"`, `"test"` or `NULL`\cr
56+
#' * `validate` :: `numeric(1)`, `"predefined"`, `"test"` or `NULL`\cr
5757
#' How to construct the validation data. This also has to be configured in the individual learners wrapped by
5858
#' `PipeOpLearner`, see [`set_validate.GraphLearner`] on how to configure this.
5959
#'
@@ -111,10 +111,10 @@ GraphLearner = R6Class("GraphLearner", inherit = Learner,
111111
assert_subset(task_type, mlr_reflections$task_types$type)
112112

113113
private$.can_validate = some(learner_wrapping_pipeops(graph), function(po) "validation" %in% po$learner$properties)
114-
private$.can_inner_tuning = some(learner_wrapping_pipeops(graph), function(po) "inner_tuning" %in% po$learner$properties)
114+
private$.can_internal_tuning = some(learner_wrapping_pipeops(graph), function(po) "internal_tuning" %in% po$learner$properties)
115115

116116
properties = setdiff(mlr_reflections$learner_properties[[task_type]],
117-
c("validation", "inner_tuning")[!c(private$.can_validate, private$.can_inner_tuning)])
117+
c("validation", "internal_tuning")[!c(private$.can_validate, private$.can_internal_tuning)])
118118

119119
super$initialize(id = id, task_type = task_type,
120120
feature_types = mlr_reflections$task_feature_types,
@@ -153,13 +153,13 @@ GraphLearner = R6Class("GraphLearner", inherit = Learner,
153153
}
154154
),
155155
active = list(
156-
inner_valid_scores = function(rhs) {
156+
internal_valid_scores = function(rhs) {
157157
assert_ro_binding(rhs)
158-
self$state$inner_valid_scores
158+
self$state$internal_valid_scores
159159
},
160-
inner_tuned_values = function(rhs) {
160+
internal_tuned_values = function(rhs) {
161161
assert_ro_binding(rhs)
162-
self$state$inner_tuned_values
162+
self$state$internal_tuned_values
163163
},
164164
validate = function(rhs) {
165165
if (!missing(rhs)) {
@@ -212,25 +212,25 @@ GraphLearner = R6Class("GraphLearner", inherit = Learner,
212212
.graph = NULL,
213213
.validate = NULL,
214214
.can_validate = NULL,
215-
.can_inner_tuning = NULL,
216-
.extract_inner_tuned_values = function() {
215+
.can_internal_tuning = NULL,
216+
.extract_internal_tuned_values = function() {
217217
if (!private$.can_validate) return(NULL)
218218
itvs = unlist(map(
219219
learner_wrapping_pipeops(self$graph_model), function(po) {
220-
if (exists("inner_tuned_values", po$learner)) {
221-
po$learner_model$inner_tuned_values
220+
if (exists("internal_tuned_values", po$learner)) {
221+
po$learner_model$internal_tuned_values
222222
}
223223
}
224224
), recursive = FALSE)
225225
if (is.null(itvs) || !length(itvs)) return(named_list())
226226
itvs
227227
},
228-
.extract_inner_valid_scores = function() {
229-
if (!private$.can_inner_tuning) return(NULL)
228+
.extract_internal_valid_scores = function() {
229+
if (!private$.can_internal_tuning) return(NULL)
230230
ivs = unlist(map(
231231
learner_wrapping_pipeops(self$graph_model), function(po) {
232-
if (exists("inner_valid_scores", po$learner)) {
233-
po$learner_model$inner_valid_scores
232+
if (exists("internal_valid_scores", po$learner)) {
233+
po$learner_model$internal_valid_scores
234234
}
235235
}
236236
), recursive = FALSE)
@@ -314,11 +314,11 @@ GraphLearner = R6Class("GraphLearner", inherit = Learner,
314314
#' 2. On the level of the [`Learner`]s that are wrapped by [`PipeOpLearner`] and [`PipeOpLearnerCV`], which specifies
315315
#' which pipeops actually make use of the validation data.
316316
#' All learners wrapped by [`PipeOpLearner`] and [`PipeOpLearnerCV`] should in almost all cases either set it
317-
#' to `NULL` (disable) or `"inner_valid"` (enable).
317+
#' to `NULL` (disable) or `"predefined"` (enable).
318318
#'
319319
#' @param learner ([`GraphLearner`])\cr
320320
#' The graph learner to configure.
321-
#' @param validate (`numeric(1)`, `"inner_valid"`, `"test"`, or `NULL`)\cr
321+
#' @param validate (`numeric(1)`, `"predefined"`, `"test"`, or `NULL`)\cr
322322
#' How to set the `$validate` field of the learner.
323323
#' If set to `NULL` all validation is disabled, both on the graph learner level, but also for all pipeops.
324324
#' @param ids (`NULL` or `character()`)\cr
@@ -384,7 +384,7 @@ set_validate.GraphLearner = function(learner, validate, ids = NULL, args = list(
384384
walk(ids, function(poid) {
385385
# learner might be another GraphLearner / AutoTuner so we call into set_validate() again
386386
withCallingHandlers({
387-
invoke(set_validate, learner = learner$graph$pipeops[[poid]]$learner, .args = insert_named(list(validate = "inner_valid"), args[[poid]]))
387+
invoke(set_validate, learner = learner$graph$pipeops[[poid]]$learner, .args = insert_named(list(validate = "predefined"), args[[poid]]))
388388
}, error = function(e) {
389389
e$message = sprintf("Failed to set validate for PipeOp '%s':\n%s", poid, e$message)
390390
stop(e)
@@ -401,12 +401,12 @@ set_validate.GraphLearner = function(learner, validate, ids = NULL, args = list(
401401

402402

403403
#' @export
404-
disable_inner_tuning.GraphLearner = function(learner, ids, ...) {
404+
disable_internal_tuning.GraphLearner = function(learner, ids, ...) {
405405
pvs = learner$param_set$values
406406
on.exit({learner$param_set$values = pvs}, add = TRUE)
407407
if (length(ids)) {
408408
walk(learner_wrapping_pipeops(learner), function(po) {
409-
disable_inner_tuning(po$learner, ids = po$param_set$ids()[sprintf("%s.%s", po$id, po$param_set$ids()) %in% ids])
409+
disable_internal_tuning(po$learner, ids = po$param_set$ids()[sprintf("%s.%s", po$id, po$param_set$ids()) %in% ids])
410410
})
411411
}
412412
on.exit()

R/PipeOpImpute.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ PipeOpImpute = R6Class("PipeOpImpute",
195195

196196
self$state$outtasklayout = copy(intask$feature_types)
197197

198-
if (!is.null(intask$inner_valid_task)) {
199-
intask$inner_valid_task = private$.predict(list(intask$inner_valid_task))[[1L]]
198+
if (!is.null(intask$internal_valid_task)) {
199+
intask$internal_valid_task = private$.predict(list(intask$internal_valid_task))[[1L]]
200200
}
201201

202202
list(intask)

R/PipeOpTaskPreproc.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ PipeOpTaskPreproc = R6Class("PipeOpTaskPreproc",
221221
self$state$outtasklayout = copy(intask$feature_types)
222222
self$state$outtaskshell = intask$data(rows = intask$row_ids[0])
223223

224-
if (!is.null(intask$inner_valid_task)) {
224+
if (!is.null(intask$internal_valid_task)) {
225225
# we call into .predict() and not .predict_task() to not put the burden
226226
# of subsetting the features etc. on the PipeOp overwriting .predict_task
227-
intask$inner_valid_task = private$.predict(list(intask$inner_valid_task))[[1L]]
227+
intask$internal_valid_task = private$.predict(list(intask$internal_valid_task))[[1L]]
228228
}
229229

230230
if (do_subset) {

inst/testthat/helper_functions.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,15 @@ expect_datapreproc_pipeop_class = function(poclass, constargs = list(), task,
441441
tasktrain$row_roles$use = tasktrain$row_roles$use[seq(1, n_use - 2)]
442442

443443
taskpredict = tasktrain$clone(deep = TRUE)
444-
taskpredict$row_roles$use = taskpredict$inner_valid_task$row_roles$use
445-
taskpredict$inner_valid_task = NULL
444+
taskpredict$row_roles$use = taskpredict$internal_valid_task$row_roles$use
445+
taskpredict$internal_valid_task = NULL
446446

447447
taskouttrain = po$train(list(tasktrain))[[1L]]
448448
taskoutpredict = po$predict(list(taskpredict))[[1L]]
449449

450450
# other columns like weights are present during traing but not during predict
451451
cols = unname(unlist(taskouttrain$col_roles[c("feature", "target")]))
452-
dtrain = taskouttrain$inner_valid_task$data(cols = cols)
452+
dtrain = taskouttrain$internal_valid_task$data(cols = cols)
453453
dpredict = taskoutpredict$data(cols = cols)
454454
expect_permutation(colnames(dtrain), colnames(dpredict))
455455
expect_equal(nrow(dtrain), nrow(dpredict))

man/mlr_learners_avg.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_learners_graph.Rd

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_pipeops_tunethreshold.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/set_validate.GraphLearner.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_GraphLearner.R

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -578,86 +578,86 @@ test_that("GraphLearner hashes", {
578578

579579
})
580580

581-
test_that("validation, inner_valid_scores", {
581+
test_that("validation, internal_valid_scores", {
582582
# None of the Learners can do validation -> NULL
583583
glrn1 = as_learner(as_graph(lrn("classif.rpart")))$train(tsk("iris"))
584584
expect_false("validation" %in% glrn1$properties)
585-
expect_equal(glrn1$inner_valid_scores, NULL)
585+
expect_equal(glrn1$internal_valid_scores, NULL)
586586

587587
glrn2 = as_learner(as_graph(lrn("classif.debug")))
588588
expect_true("validation" %in% glrn2$properties)
589589
set_validate(glrn2, 0.2)
590590
expect_equal(glrn2$validate, 0.2)
591-
expect_equal(glrn2$graph$pipeops$classif.debug$learner$validate, "inner_valid")
591+
expect_equal(glrn2$graph$pipeops$classif.debug$learner$validate, "predefined")
592592
glrn2$train(tsk("iris"))
593-
expect_list(glrn2$inner_valid_scores, types = "numeric")
594-
expect_equal(names(glrn2$inner_valid_scores), "classif.debug.acc")
593+
expect_list(glrn2$internal_valid_scores, types = "numeric")
594+
expect_equal(names(glrn2$internal_valid_scores), "classif.debug.acc")
595595

596596
set_validate(glrn2, NULL)
597597
glrn2$train(tsk("iris"))
598-
expect_true(is.null(glrn2$inner_valid_scores))
598+
expect_true(is.null(glrn2$internal_valid_scores))
599599

600-
# No validation set specified --> No inner_valid_scores
600+
# No validation set specified --> No internal_valid_scores
601601
expect_equal(
602-
as_learner(as_graph(lrn("classif.debug")))$train(tsk("iris"))$inner_valid_scores,
602+
as_learner(as_graph(lrn("classif.debug")))$train(tsk("iris"))$internal_valid_scores,
603603
NULL
604604
)
605605
glrn2 = as_learner(as_graph(lrn("classif.debug")))
606606
})
607607

608-
test_that("inner_tuned_values", {
609-
# no inner tuning support -> NULL
608+
test_that("internal_tuned_values", {
609+
# no internal tuning support -> NULL
610610
task = tsk("iris")
611611
glrn1 = as_learner(as_graph(lrn("classif.rpart")))$train(task)
612-
expect_false("inner_tuning" %in% glrn1$properties)
613-
expect_equal(glrn1$inner_tuned_values, NULL)
612+
expect_false("internal_tuning" %in% glrn1$properties)
613+
expect_equal(glrn1$internal_tuned_values, NULL)
614614

615-
# learner with inner tuning
615+
# learner with internal tuning
616616
glrn2 = as_learner(as_graph(lrn("classif.debug")))
617-
expect_true("inner_tuning" %in% glrn2$properties)
618-
expect_equal(glrn2$inner_tuned_values, NULL)
617+
expect_true("internal_tuning" %in% glrn2$properties)
618+
expect_equal(glrn2$internal_tuned_values, NULL)
619619
glrn2$train(task)
620-
expect_equal(glrn2$inner_tuned_values, named_list())
620+
expect_equal(glrn2$internal_tuned_values, named_list())
621621
glrn2$param_set$set_values(classif.debug.early_stopping = TRUE, classif.debug.iter = 1000)
622622
set_validate(glrn2, 0.2)
623623
glrn2$train(task)
624-
expect_equal(names(glrn2$inner_tuned_values), "classif.debug.iter")
624+
expect_equal(names(glrn2$internal_tuned_values), "classif.debug.iter")
625625
})
626626

627-
test_that("disable_inner_tuning", {
627+
test_that("disable_internal_tuning", {
628628
glrn = as_learner(as_pipeop(lrn("classif.debug", iter = 100, early_stopping = TRUE)))
629-
disable_inner_tuning(glrn, "classif.debug.iter")
629+
disable_internal_tuning(glrn, "classif.debug.iter")
630630
expect_false(glrn$graph$pipeops$classif.debug$param_set$values$early_stopping)
631-
expect_error(disable_inner_tuning(glrn, "classif.debug.abc"), "subset of")
631+
expect_error(disable_internal_tuning(glrn, "classif.debug.abc"), "subset of")
632632
})
633633

634634
test_that("set_validate", {
635635
glrn = as_learner(as_pipeop(lrn("classif.debug", validate = 0.3)))
636636
set_validate(glrn, "test")
637637
expect_equal(glrn$validate, "test")
638-
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, "inner_valid")
638+
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, "predefined")
639639
set_validate(glrn, NULL)
640640
expect_equal(glrn$validate, NULL)
641641
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, NULL)
642642
set_validate(glrn, 0.2, ids = "classif.debug")
643643
expect_equal(glrn$validate, 0.2)
644-
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, "inner_valid")
644+
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, "predefined")
645645

646646

647647
glrn = as_learner(ppl("stacking", list(lrn("classif.debug"), lrn("classif.featureless")),
648648
lrn("classif.debug", id = "final")))
649649
set_validate(glrn, 0.3, ids = c("classif.debug", "final"))
650650
expect_equal(glrn$validate, 0.3)
651-
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, "inner_valid")
652-
expect_equal(glrn$graph$pipeops$final$learner$validate, "inner_valid")
651+
expect_equal(glrn$graph$pipeops$classif.debug$learner$validate, "predefined")
652+
expect_equal(glrn$graph$pipeops$final$learner$validate, "predefined")
653653

654654

655655
glrn = as_learner(ppl("stacking", list(lrn("classif.debug"), lrn("classif.featureless")),
656656
lrn("classif.debug", id = "final")))
657657
glrn2 = as_learner(po("learner", glrn, id = "polearner"))
658658
set_validate(glrn2, validate = 0.25, ids = "polearner", args = list(polearner = list(ids = "final")))
659659
expect_equal(glrn2$validate, 0.25)
660-
expect_equal(glrn2$graph$pipeops$polearner$learner$validate, "inner_valid")
661-
expect_equal(glrn2$graph$pipeops$polearner$learner$graph$pipeops$final$learner$validate, "inner_valid")
660+
expect_equal(glrn2$graph$pipeops$polearner$learner$validate, "predefined")
661+
expect_equal(glrn2$graph$pipeops$polearner$learner$graph$pipeops$final$learner$validate, "predefined")
662662
expect_equal(glrn2$graph$pipeops$polearner$learner$graph$pipeops$classif.debug$learner$validate, NULL)
663663
})

0 commit comments

Comments
 (0)