Create
a
PipeOp
frommlr_pipeops
from given IDa
PipeOpLearner
from aLearner
objecta
PipeOpFilter
from aFilter
objecta
PipeOpSelect
from aSelector
objecta clone of a
PipeOp
from a givenPipeOp
(possibly with changed settings)
The object is initialized with given parameters and param_vals
.
po()
taks a single obj
(PipeOp
id, Learner
, ...) and converts
it to a PipeOp
. pos()
(with plural-s) takes either a character
-vector, or a
list of objects, and creates a list
of PipeOp
s.
Arguments
- .obj
[any]
The object from which to construct aPipeOp
. If this is acharacter(1)
, it is looked up in themlr_pipeops
dictionary. Otherwise, it is converted to aPipeOp
.- ...
any
Additional parameters to give to constructed object. This may be an argument of the constructor of thePipeOp
, in which case it is given to this constructor; or it may be a parameter value, in which case it is given to theparam_vals
argument of the constructor.- .objs
character
|list
Either acharacter
ofPipeOp
s to look up inmlr_pipeops
, or a list of other objects to be converted to aPipeOp
. If this is a namedlist
, then the names are used as$id
slot for the resultingPipeOp
s.
Examples
library("mlr3")
po("learner", lrn("classif.rpart"), cp = 0.3)
#> PipeOp: <classif.rpart> (not trained)
#> values: <xval=0, cp=0.3>
#> Input channels <name [train type, predict type]>:
#> input [TaskClassif,TaskClassif]
#> Output channels <name [train type, predict type]>:
#> output [NULL,PredictionClassif]
po(lrn("classif.rpart"), cp = 0.3)
#> PipeOp: <classif.rpart> (not trained)
#> values: <xval=0, cp=0.3>
#> Input channels <name [train type, predict type]>:
#> input [TaskClassif,TaskClassif]
#> Output channels <name [train type, predict type]>:
#> output [NULL,PredictionClassif]
# is equivalent with:
mlr_pipeops$get("learner", lrn("classif.rpart"),
param_vals = list(cp = 0.3))
#> PipeOp: <classif.rpart> (not trained)
#> values: <xval=0, cp=0.3>
#> Input channels <name [train type, predict type]>:
#> input [TaskClassif,TaskClassif]
#> Output channels <name [train type, predict type]>:
#> output [NULL,PredictionClassif]
pos(c("pca", original = "nop"))
#> Error in (function (classes, fdef, mtable) { methods <- .findInheritedMethods(classes, fdef, mtable) if (length(methods) == 1L) return(methods[[1L]]) else if (length(methods) == 0L) { cnames <- paste0("\"", vapply(classes, as.character, ""), "\"", collapse = ", ") stop(gettextf("unable to find an inherited method for function %s for signature %s", sQuote(fdef@generic), sQuote(cnames)), domain = NA) } else stop("Internal error in finding inherited methods; didn't return a unique method", domain = NA)})(list("character"), new("standardGeneric", .Data = function (x) standardGeneric("pos"), generic = structure("pos", package = "BiocGenerics"), package = "BiocGenerics", group = list(), valueClass = character(0), signature = "x", default = NULL, skeleton = (function (x) stop(gettextf("invalid call in method dispatch to '%s' (no default method)", "pos"), domain = NA))(x)), <environment>): unable to find an inherited method for function ‘pos’ for signature ‘"character"’