mlr_pipeops_learner {mlr3pipelines} | R Documentation |
Wrap a Learner into a PipeOp
Description
Wraps an mlr3::Learner
into a PipeOp
.
Inherits the $param_set
(and therefore $param_set$values
) from the Learner
it is constructed from.
Using PipeOpLearner
, it is possible to embed mlr3::Learner
s into Graph
s, which themselves can be
turned into Learners using GraphLearner
. This way, preprocessing and ensemble methods can be included
into a machine learning pipeline which then can be handled as singular object for resampling, benchmarking
and tuning.
Format
R6Class
object inheriting from PipeOp
.
Construction
PipeOpLearner$new(learner, id = NULL, param_vals = list())
-
learner
::Learner
|character(1)
Learner
to wrap, or a string identifying aLearner
in themlr3::mlr_learners
Dictionary
. This argument is always cloned; to access theLearner
insidePipeOpLearner
by-reference, use$learner
.
-
id
::character(1)
Identifier of the resulting object, internally defaulting to theid
of theLearner
being wrapped. -
param_vals
:: namedlist
List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Defaultlist()
.
Input and Output Channels
PipeOpLearner
has one input channel named "input"
, taking a Task
specific to the Learner
type given to learner
during construction; both during training and prediction.
PipeOpLearner
has one output channel named "output"
, producing NULL
during training and a Prediction
subclass
during prediction; this subclass is specific to the Learner
type given to learner
during construction.
The output during prediction is the Prediction
on the prediction input data, produced by the Learner
trained on the training input data.
State
The $state
is set to the $state
slot of the Learner
object. It is a named list
with members:
-
model
::any
Model created by theLearner
's$.train()
function. -
train_log
::data.table
with columnsclass
(character
),msg
(character
)
Errors logged during training. -
train_time
::numeric(1)
Training time, in seconds. -
predict_log
::NULL
|data.table
with columnsclass
(character
),msg
(character
)
Errors logged during prediction. -
predict_time
::NULL
|numeric(1)
Prediction time, in seconds.
Parameters
The parameters are exactly the parameters of the Learner
wrapped by this object.
Internals
The $state
is currently not updated by prediction, so the $state$predict_log
and $state$predict_time
will always be NULL
.
Fields
Fields inherited from PipeOp
, as well as:
-
learner
::Learner
Learner
that is being wrapped. Read-only. -
learner_model
::Learner
Learner
that is being wrapped. This learner contains the model if thePipeOp
is trained. Read-only. -
validate
::"predefined"
orNULL
This field can only be set forLearner
s that have the"validation"
property. Setting the field to"predefined"
means that the wrappedLearner
will use the internal validation task, otherwise it will be ignored. Note that specifying how the validation data is created is possible via the$validate
field of theGraphLearner
. For eachPipeOp
it is then only possible to either use it ("predefined"
) or not use it (NULL
). Also seeset_validate.GraphLearner
for more information. -
internal_tuned_values
:: namedlist()
orNULL
The internally tuned values if the wrappedLearner
supports internal tuning,NULL
otherwise. -
internal_valid_scores
:: namedlist()
orNULL
The internal validation scores if the wrappedLearner
supports internal validation,NULL
otherwise.
Methods
Methods inherited from PipeOp
.
See Also
https://mlr-org.com/pipeops.html
Other PipeOps:
PipeOp
,
PipeOpEnsemble
,
PipeOpImpute
,
PipeOpTargetTrafo
,
PipeOpTaskPreproc
,
PipeOpTaskPreprocSimple
,
mlr_pipeops
,
mlr_pipeops_boxcox
,
mlr_pipeops_branch
,
mlr_pipeops_chunk
,
mlr_pipeops_classbalancing
,
mlr_pipeops_classifavg
,
mlr_pipeops_classweights
,
mlr_pipeops_colapply
,
mlr_pipeops_collapsefactors
,
mlr_pipeops_colroles
,
mlr_pipeops_copy
,
mlr_pipeops_datefeatures
,
mlr_pipeops_encode
,
mlr_pipeops_encodeimpact
,
mlr_pipeops_encodelmer
,
mlr_pipeops_featureunion
,
mlr_pipeops_filter
,
mlr_pipeops_fixfactors
,
mlr_pipeops_histbin
,
mlr_pipeops_ica
,
mlr_pipeops_imputeconstant
,
mlr_pipeops_imputehist
,
mlr_pipeops_imputelearner
,
mlr_pipeops_imputemean
,
mlr_pipeops_imputemedian
,
mlr_pipeops_imputemode
,
mlr_pipeops_imputeoor
,
mlr_pipeops_imputesample
,
mlr_pipeops_kernelpca
,
mlr_pipeops_missind
,
mlr_pipeops_modelmatrix
,
mlr_pipeops_multiplicityexply
,
mlr_pipeops_multiplicityimply
,
mlr_pipeops_mutate
,
mlr_pipeops_nmf
,
mlr_pipeops_nop
,
mlr_pipeops_ovrsplit
,
mlr_pipeops_ovrunite
,
mlr_pipeops_pca
,
mlr_pipeops_proxy
,
mlr_pipeops_quantilebin
,
mlr_pipeops_randomprojection
,
mlr_pipeops_randomresponse
,
mlr_pipeops_regravg
,
mlr_pipeops_removeconstants
,
mlr_pipeops_renamecolumns
,
mlr_pipeops_replicate
,
mlr_pipeops_scale
,
mlr_pipeops_scalemaxabs
,
mlr_pipeops_scalerange
,
mlr_pipeops_select
,
mlr_pipeops_smote
,
mlr_pipeops_spatialsign
,
mlr_pipeops_subsample
,
mlr_pipeops_targetinvert
,
mlr_pipeops_targetmutate
,
mlr_pipeops_targettrafoscalerange
,
mlr_pipeops_textvectorizer
,
mlr_pipeops_threshold
,
mlr_pipeops_tunethreshold
,
mlr_pipeops_unbranch
,
mlr_pipeops_updatetarget
,
mlr_pipeops_vtreat
,
mlr_pipeops_yeojohnson
Other Meta PipeOps:
mlr_pipeops_learner_cv
Examples
library("mlr3")
task = tsk("iris")
learner = lrn("classif.rpart", cp = 0.1)
lrn_po = mlr_pipeops$get("learner", learner)
lrn_po$train(list(task))
lrn_po$predict(list(task))