CPOConstructor: Constructor for CPO Objects

CPOConstructorR Documentation

Constructor for CPO Objects


CPO objects are created by calling CPOConstructors, which are R functions that have some parameters in common, use a convenient print.CPOConstructor generic, and always return a CPO object. The mlrCPO package provides many CPOConstructor functions, which can be listed using listCPO. It is also possible to create custom CPOConstructors using makeCPO, makeCPORetrafoless, link{makeCPOTargetOp}, and makeCPOExtendedTrafo.



[character(1) | NULL]
ID to use for the CPO. if NULL is given, this defaults to a name describing the action performed by the CPO, which can be retrieved using getCPOName. The ID is used to identify the CPO in print messages, and is prefixed to the CPO's hyperparameter names. This is can be used to avoid name clashes when composing a CPO with another CPO or Learner with hyperparameters with clashing names. Default is NULL.


Which hyperparameters to export. This can be a character vector naming the hyperparameters to export (excluding the ID), or a character(1) with one of the special values:

“export.all” export all parameters
“export.default” exp. params that are exp. by def
“export.set” exp. params set in construct call
“export.default.set” intersection of “default” and “set”
“export.unset” params not set in construct call
“export.default.unset” isct. of “default” and “unset”
“export.all.plus” not yet supported

Default is “export.default”.


[character | NULL]
Type of columns to affect. May be a subset of “numeric”, “factor”, “ordered”, “other”, or can be or NULL to match all columns. Default is NULL.


Indices of feature columns to affect. The order of indices given is respected. Default is integer(0).


Feature names of feature columns to affect. The order of names given is respected. Default is character(0).


[character(1) | NULL]
grep pattern to match feature names by. Default is NULL (no pattern matching)


Whether to affect all features not matched by other affect.* parameters. Default is FALSE.


Ignore case when matching features with affect.pattern; see grep. Has no effect when affect.pattern is NULL. Default is FALSE.


Use Perl-style regular expressions for affect.pattern; see grep. Has no effect when affect.pattern is NULL, or when affect.pattern.fixed is TRUE. Default is FALSE.


Use fixed matching instead of regular expressions for affect.pattern; see grep. Has no effect when affect.pattern is NULL. Default is FALSE.


[CPO] the constructed CPO.

CPO creation

CPOConstructors can be called like any R function, with any parameters given. Besides parameters that are common to most CPOConstructors (listed below), it is possible to set CPO-specific hyperparameters in the construction. Parameters that are being exported can also be modified later using the CPO object, see the documentation there.

affect.* parameters

When creating a CPO, it is possible to choose which columns of the given data the CPO operates on, and which columns it will ignore. This is done using the affect.* parameters. It is possible to choose columns by types, indices, names, or a regular expression matching names.

See Also

print.CPOConstructor for possibly verbose printing.

Other CPO lifecycle related: CPOLearner, CPOTrained, CPO, NULLCPO, %>>%(), attachCPO(), composeCPO(), getCPOClass(), getCPOConstructor(), getCPOTrainedCPO(), identicalCPO(), makeCPO()

Other CPOConstructor related: getCPOClass(), getCPOConstructor(), getCPOName(), identicalCPO(), makeCPO(), print.CPOConstructor()


class(cpoPca)  # c("CPOConstructor", "function")
print(cpoPca)  # default printer
print(cpoPca, verbose = TRUE)  # shows the trafo / retrafo functions

cpoPca()  # creating a CPO
class(cpoPca())  # c("CPOPrimitive", "CPO")

mlrCPO documentation built on Nov. 18, 2022, 1:05 a.m.