Lrner {fuseMLR} | R Documentation |
Lrner Class
Description
This class implements a learner. A Lrner object can only exist as a component of a TrainLayer or a TrainMetaLayer object.
Methods
Public methods
Method new()
Initialize a default parameters list.
Usage
Lrner$new( id, package = NULL, lrn_fct, param_train_list, param_pred_list = list(), train_layer, na_action = "na.rm" )
Arguments
id
character
Learner ID.package
character
Package that implements the learn function. If NULL, thelrn_fct
character
learn function is called from the current environment.param_train_list
list
List of parameter for training.param_pred_list
list
List of parameter for testing. Learn parameters.train_layer
TrainLayer
Layer on which the learner is stored.na_action
character
Handling of missing values. Set to "na.keep" to keep missing values, "na.rm" to remove individuals with missing values or "na.impute" (only applicable on meta-data) to impute missing values in meta-data. Only median and mode based imputations are actually handled. With the "na.keep" option, ensure that the provided learner can handle missing values.
Method print()
Printer
Usage
Lrner$print(...)
Arguments
...
any
Method summary()
Printer
Usage
Lrner$summary(...)
Arguments
...
any
Method interface()
Learner and prediction parameter interface. Use this function
to provide how the following parameters are named in the learning
function (lrn_fct
) you provided when creating the learner, or in the predicting function.
Usage
Lrner$interface( x = "x", y = "y", object = "object", data = "data", extract_pred_fct = NULL )
Arguments
x
character
Name of the argument to pass the matrix of independent variables in the original learning function.y
character
Name of the argument to pass the response variable in the original learning function.object
character
Name of the argument to pass the model in the original predicting function.data
character
Name of the argument to pass new data in the original predicting function.extract_pred_fct
character
orfunction
If the predict function that is called for the model does not return a vector, then use this argument to specify a (or a name of a) function that can be used to extract vector of predictions. Default value is NULL, if predictions are in a vector.
Method train()
Tains the current learner (from class Lrner) on the current training data (from class TrainData).
Usage
Lrner$train(ind_subset = NULL, use_var_sel = FALSE, verbose = TRUE)
Arguments
ind_subset
vector
Individual ID subset on which the training will be performed.use_var_sel
boolean
If TRUE, variable selection is performed before training.verbose
boolean
Warning messages will be displayed if set to TRUE.
Returns
The resulting model, from class Model, is returned.
Method getTrainLayer()
The current layer is returned.
Usage
Lrner$getTrainLayer()
Returns
TrainLayer object.
Method getNaRm()
The current layer is returned.
Usage
Lrner$getNaRm()
Method getNaAction()
The current layer is returned.
Usage
Lrner$getNaAction()
Method getId()
Getter of the current learner ID.
Usage
Lrner$getId()
Returns
The current learner ID.
Method getPackage()
Getter of the learner package implementing the learn function.
Usage
Lrner$getPackage()
Returns
The name of the package implementing the learn function.
Method getIndSubset()
Getter of the learner package implementing the learn function.
Usage
Lrner$getIndSubset()
Returns
The name of the package implementing the learn function.
Method getVarSubset()
Getter of the variable subset used for training.
Usage
Lrner$getVarSubset()
Returns
The list of variables used for training is returned.
Method getParamPred()
Getter predicting parameter list.
Usage
Lrner$getParamPred()
Returns
The list of predicting parameters.
Method getParamInterface()
The current parameter interface is returned.
Usage
Lrner$getParamInterface()
Returns
A data.frame of interface.
Method getExtractPred()
The function to extract predicted values is returned.
Usage
Lrner$getExtractPred()
Returns
A data.frame of interface.