11# ' @title Wrap a Learner into a PipeOp with Cross-validation Plus Confidence Intervals as Predictions
22# '
33# ' @usage NULL
4- # ' @name mlr_pipeops_learner_cv_plus
4+ # ' @name mlr_pipeops_learner_pi_cvplus
55# ' @format [`R6Class`][R6::R6Class] object inheriting from [`PipeOp`].
66# '
77# ' @description
88# ' Wraps an [`mlr3::Learner`] into a [`PipeOp`].
99# '
1010# ' Inherits the `$param_set` (and therefore `$param_set$values`) from the [`Learner`][mlr3::Learner] it is constructed from.
1111# '
12- # ' Using [`PipeOpLearnerCVPlus `], it is possible to embed a [`mlr3::Learner`] into a [`Graph`].
13- # ' [`PipeOpLearnerCVPlus `] can then be used to perform cross validation plus (or jackknife plus).
14- # ' During training, [`PipeOpLearnerCVPlus `] performs cross validation on the training data.
12+ # ' Using [`PipeOpLearnerPICVPlus `], it is possible to embed a [`mlr3::Learner`] into a [`Graph`].
13+ # ' [`PipeOpLearnerPICVPlus `] can then be used to perform cross validation plus (or jackknife plus).
14+ # ' During training, [`PipeOpLearnerPICVPlus `] performs cross validation on the training data.
1515# ' During prediction, the models from the training stage are used to construct predictive confidence intervals for the prediction data based on
1616# ' out-of-fold residuals and out-of-fold predictions.
1717# '
1818# ' @section Construction:
1919# ' ```
20- # ' PipeOpLearnerCVPlus $new(learner, id = NULL, param_vals = list())
20+ # ' PipeOpLearnerPICVPlus $new(learner, id = NULL, param_vals = list())
2121# ' ```
2222# '
2323# ' * `learner` :: [`LearnerRegr`][mlr3::LearnerRegr]
2424# ' [`LearnerRegr`][mlr3::LearnerRegr] to use for the cross validation models in the Cross Validation Plus method.
25- # ' This argument is always cloned; to access the [`Learner`][mlr3::Learner] inside `PipeOpLearnerCVPlus ` by-reference, use `$learner`.\cr
25+ # ' This argument is always cloned; to access the [`Learner`][mlr3::Learner] inside `PipeOpLearnerPICVPlus ` by-reference, use `$learner`.\cr
2626# ' * `id` :: `character(1)`
2727# ' Identifier of the resulting object, internally defaulting to the `id` of the [`Learner`][mlr3::Learner] being wrapped.
2828# ' * `param_vals` :: named `list`\cr
2929# ' List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction.
3030# ' Default is `list()`.
3131# '
3232# ' @section Input and Output Channels:
33- # ' [`PipeOpLearnerCVPlus `] has one input channel named `"input"`, taking a [`Task`][mlr3::Task] specific to the [`Learner`][mlr3::Learner]
33+ # ' [`PipeOpLearnerPICVPlus `] has one input channel named `"input"`, taking a [`Task`][mlr3::Task] specific to the [`Learner`][mlr3::Learner]
3434# ' type given to `learner` during construction; both during training and prediction.
3535# '
36- # ' [`PipeOpLearnerCVPlus `] has one output channel named `"output"`, producing `NULL` during training and a [`PredictionRegr`][mlr3::PredictionRegr]
36+ # ' [`PipeOpLearnerPICVPlus `] has one output channel named `"output"`, producing `NULL` during training and a [`PredictionRegr`][mlr3::PredictionRegr]
3737# ' during prediction.
3838# '
3939# ' The output during prediction is a [`PredictionRegr`][mlr3::PredictionRegr] with `predict_type` `quantiles` on the prediction input data.
6565# ' [`Learner`][mlr3::Learner] that is being wrapped.
6666# ' Read-only.
6767# ' * `learner_model` :: [`Learner`][mlr3::Learner] or `list`\cr
68- # ' If the [`PipeOpLearnerCVPlus `] has been trained, this is a `list` containing the [`Learner`][mlr3::Learner]s of the cross validation models.
68+ # ' If the [`PipeOpLearnerPICVPlus `] has been trained, this is a `list` containing the [`Learner`][mlr3::Learner]s of the cross validation models.
6969# ' Otherwise, this contains the [`Learner`][mlr3::Learner] that is being wrapped.
7070# ' Read-only.
7171# ' * `predict_type`\cr
72- # ' Predict type of the [`PipeOpLearnerCVPlus `], which is always `"response" "quantiles"`.
72+ # ' Predict type of the [`PipeOpLearnerPICVPlus `], which is always `"response" "quantiles"`.
7373# ' This can be different to the predict type of the [`Learner`][mlr3::Learner] that is being wrapped.
7474# '
7575# ' @section Methods:
8989# '
9090# ' task = tsk("mtcars")
9191# ' learner = lrn("regr.rpart")
92- # ' lrncvplus_po = mlr_pipeops$get("learner_cv_plus ", learner)
92+ # ' lrncvplus_po = mlr_pipeops$get("learner_pi_cvplus ", learner)
9393# '
9494# ' lrncvplus_po$train(list(task))
9595# ' lrncvplus_po$predict(list(task))
9696# ' \dontshow{ \} }
97- PipeOpLearnerCVPlus = R6Class(" PipeOpLearnerCVPlus " ,
97+ PipeOpLearnerPICVPlus = R6Class(" PipeOpLearnerPICVPlus " ,
9898 inherit = PipeOp ,
9999 public = list (
100100 initialize = function (learner , id = NULL , param_vals = list ()) {
@@ -103,7 +103,7 @@ PipeOpLearnerCVPlus = R6Class("PipeOpLearnerCVPlus",
103103 type = private $ .learner $ task_type
104104
105105 if (" regr" != type ) {
106- stop(" PipeOpLearnerCVPlus only supports regression." )
106+ stop(" PipeOpLearnerPICVPlus only supports regression." )
107107 }
108108
109109 task_type = mlr_reflections $ task_types [type , mult = " first" ]$ task
@@ -158,7 +158,7 @@ PipeOpLearnerCVPlus = R6Class("PipeOpLearnerCVPlus",
158158 }
159159 ),
160160 private = list (
161- .state_class = " pipeop_learner_cv_plus_state " ,
161+ .state_class = " pipeop_learner_pi_cvplus_state " ,
162162
163163 .train = function (inputs ) {
164164 task = inputs [[1L ]]
@@ -216,7 +216,7 @@ PipeOpLearnerCVPlus = R6Class("PipeOpLearnerCVPlus",
216216)
217217
218218# ' @export
219- marshal_model.pipeop_learner_cv_plus_state = function (model , inplace = FALSE , ... ) {
219+ marshal_model.pipeop_learner_pi_cvplus_state = function (model , inplace = FALSE , ... ) {
220220 # Note that a Learner state contains other reference objects, but we don't clone them here, even when inplace
221221 # is FALSE. For our use-case this is just not necessary and would cause unnecessary overhead in the mlr3
222222 # workhorse function
@@ -233,12 +233,12 @@ marshal_model.pipeop_learner_cv_plus_state = function(model, inplace = FALSE, ..
233233}
234234
235235# ' @export
236- unmarshal_model.pipeop_learner_cv_plus_state_marshaled = function (model , inplace = FALSE , ... ) {
236+ unmarshal_model.pipeop_learner_pi_cvplus_state_marshaled = function (model , inplace = FALSE , ... ) {
237237 state_marshaled = model $ marshaled
238238 state_marshaled $ cv_model_states = map(state_marshaled $ cv_model_states , unmarshal_model , inplace = inplace )
239239 state_marshaled
240240}
241241
242- mlr_pipeops $ add(" learner_cv_plus " , PipeOpLearnerCVPlus , list (R6Class(" Learner" , public = list (id = " learner_cv_plus " , task_type = " regr" , param_set = ps(), packages = " mlr3pipelines" ))$ new()))
242+ mlr_pipeops $ add(" learner_pi_cvplus " , PipeOpLearnerPICVPlus , list (R6Class(" Learner" , public = list (id = " learner_pi_cvplus " , task_type = " regr" , param_set = ps(), packages = " mlr3pipelines" ))$ new()))
243243
244244
0 commit comments