diff --git a/R/Lrner.R b/R/Lrner.R index bb59e62..75b1cba 100644 --- a/R/Lrner.R +++ b/R/Lrner.R @@ -28,15 +28,15 @@ Lrner <- R6Class("Lrner", #' Learn parameters. #' @param train_layer (`TrainLayer(1)`) \cr #' Layer on which the learner is stored. - #' @param na_rm (`logical(1)`) \cr - #' If \code{TRUE}, the individuals with missing predictor values will be removed from the training dataset. + #' @param na_action `character(1)`\cr + #' 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. initialize = function (id, package = NULL, lrn_fct, param_train_list, param_pred_list = list(), train_layer, - na_rm = TRUE) { + na_action = "na.rm") { private$id = id private$package = package private$lrn_fct = lrn_fct @@ -50,11 +50,34 @@ Lrner <- R6Class("Lrner", if (!any(c("TrainLayer", "TrainMetaLayer") %in% class(train_layer))) { stop("A Lrner can only belong to a TrainLayer or a TrainMetaLayer object.") } - if (!is.logical(na_rm)) { - stop("na.rm must be a logical value\n") + # if (!is.logical(na_rm)) { + # stop("na.rm must be a logical value\n") + # } else { + # private$na_rm = na_rm + # } + impute = FALSE + if (na_action == "na.keep") { + na_rm = FALSE } else { - private$na_rm = na_rm + if (na_action == "na.rm") { + na_rm = TRUE + } else { + if (na_action == "na.impute") { + if ("TrainLayer" %in% class(train_layer)) { + stop("Imputation is not yet handled for data modalities. Please use either the 'na.keep' or the 'na.rm' option.") + } + na_rm = FALSE + impute = TRUE + # Imputation takes place in the Training class, since it + # happens after meta-data have been generated. + train_layer$getTraining()$setImpute(impute = impute) + } else { + stop("na_action must be one of 'na.fails', 'na.rm' or 'na.impute'.") + } + } } + private$na_rm = na_rm + # Instantiate a Lrner object # Remove learner if already existing if (train_layer$checkLrnerExist()) { key_class = train_layer$getKeyClass() @@ -135,7 +158,7 @@ Lrner <- R6Class("Lrner", } } param_interface = data.frame(standard = c("x_name", "y_name", "object_name", "data_name"), - original = c(x, y, object, data)) + original = c(x, y, object, data)) private$param_interface = param_interface private$extract_pred_fct = extract_pred_fct }, diff --git a/R/TrainMetaLayer.R b/R/TrainMetaLayer.R index ec36a69..eef1f12 100644 --- a/R/TrainMetaLayer.R +++ b/R/TrainMetaLayer.R @@ -157,7 +157,6 @@ TrainMetaLayer <- R6Class("TrainMetaLayer", #' The list of parameters to call the imputation function. Not yet implemented! #' @return #' A new object with the predicted values is returned. - #' @export #' impute = function (impute_fct = NULL, impute_param = NULL) { diff --git a/R/VarSel.R b/R/VarSel.R index 9a0eeda..70965f8 100644 --- a/R/VarSel.R +++ b/R/VarSel.R @@ -26,14 +26,15 @@ VarSel <- R6Class("VarSel", #' Layer on which the learner is stored. #' @param train_layer (`TrainLayer(1)`) \cr #' The training layer where to store the learner. - #' @param na_rm (`logical(1)`) \cr + #' @param na_action `character(1)`\cr + #' Handling of missing values in meta-data. 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. #' If \code{TRUE}, the individuals with missing predictor values will be removed from the training dataset. initialize = function (id, package = NULL, varsel_fct, varsel_param, train_layer, - na_rm = TRUE) { + na_action = "na.rm") { private$id = id private$package = package private$varsel_fct = varsel_fct @@ -46,11 +47,26 @@ VarSel <- R6Class("VarSel", if (!any(c("TrainLayer") %in% class(train_layer))) { stop("A variable selection tool can only belong to object of class TrainLayer.") } - if (!is.logical(na_rm)) { - stop("na.rm must be a logical value\n") + # if (!is.logical(na_rm)) { + # stop("na.rm must be a logical value\n") + # } else { + # private$na_rm = na_rm + # } + + if (na_action == "na.keep") { + na_rm = FALSE } else { - private$na_rm = na_rm + if (na_action == "na.rm") { + na_rm = TRUE + } else { + if (na_action == "na.impute") { + stop("Imputation is not yet handled for data modalities. Please use either the 'na.keep' or the 'na.rm' option.") + } else { + stop("na_action must be one of 'na.fails' or 'na.rm'.") + } + } } + private$na_rm = na_rm # Remove VarSel if already existing if (train_layer$checkVarSelExist()) { key_class = train_layer$getKeyClass() diff --git a/R/trainingFunctions.R b/R/trainingFunctions.R index 9a472b9..b83101d 100644 --- a/R/trainingFunctions.R +++ b/R/trainingFunctions.R @@ -2,24 +2,25 @@ #' @description #' Creates a [Training] object. #' -#' @param id (`character(1)`) \cr -#' @param ind_col (`character(1)`) \cr -#' Name of column of individuals IDS. -#' @param target (`character(1)`) \cr +#' @param id `character` \cr +#' Training's ID. +#' @param target_df `data.frame` \cr +#' Observed target values. A data frame with two columns: individual IDs and response variable values. +#' @param ind_col `character` \cr +#' Name of column of individuals IDs. +#' @param target `character` \cr #' Name of the target variable. -#' @param target_df (`data.frame(1)`) \cr -#' Data frame with two columns: individual IDs and response variable values. -#' @param problem_type (`character`) \cr +#' @param problem_type `character` \cr #' Either "classification" or "regression". -#' @param verbose (`boolean`) \cr +#' @param verbose `boolean` \cr #' Warning messages will be displayed if set to TRUE. #' @return #' The created [Training] object is returned. #' @export createTraining = function (id, + target_df, ind_col, target, - target_df, problem_type = "classification", verbose = TRUE) { training = Training$new( @@ -37,45 +38,45 @@ createTraining = function (id, #' @description #' Creates and store a [TrainLayer] on the [Training] object passed as argument. #' -#' @param training (`Training(1)`) \cr +#' @param training `Training` \cr #' Training object where the created layer will be stored. -#' @param train_layer_id (`character(1)`) \cr +#' @param train_layer_id `character` \cr #' ID of the [TrainLayer] to be created. -#' @param train_data (`data.frame(1)`) \cr +#' @param train_data `data.frame(1)` \cr #' Data modality to be stored in [TrainData]. -#' @param varsel_package (`character(1)`) \cr +#' @param varsel_package `character(1)` \cr #' Name of the package containing the function that implements the variable selection algorithm.\cr -#' @param varsel_fct (`character(1)`) \cr +#' @param varsel_fct `character(1)` \cr #' Name of the function that performs variable selection. For the default value NULL no variable selection will be performed. -#' @param varsel_param (`list`) \cr +#' @param varsel_param `list` \cr #' List of arguments to be passed to \code{varsel_fct}. -#' @param lrner_package (`character(1)`) \cr +#' @param lrner_package `character(1)` \cr #' Name of the package containing the function that implements the learning algorithm.\cr -#' @param lrn_fct `(character(1)` \cr +#' @param lrn_fct `character(1)` \cr #' Name of the function that that implements the learning algorithm. -#' @param param_train_list `(character(1)` \cr +#' @param param_train_list `character(1)` \cr #' List of arguments to be passed to \code{lrn_fct}. -#' @param param_pred_list `(character(1)` \cr +#' @param param_pred_list `character(1)` \cr #' List of arguments to be passed to \code{predict} when computing predictions. -#' @param na_rm \cr -#' If \code{TRUE}, the individuals with missing predictor values will be removed from the training dataset. -#' @param x (`character(1)`) \cr +#' @param na_action `character(1)`\cr +#' Handling of missing values in data a modality. Set to "na.keep" to keep missing values, or "na.rm" to remove individuals with missing values. Imputation of missing values in data modalities ist not yet handled. +#' @param x `character(1)` \cr #' If the name of the argument used by the provided original functions to pass #' the matrix of independent variable is not \code{x}, use this argument to specify how it is callled in the provided function. -#' @param y (`character(1)`) \cr +#' @param y `character(1)` \cr #' If the name of the argument used by the provided original functions to pass #' the target variable is not \code{y}, use this argument to specify how it is callled in the provided function. -#' @param object (`character(1)`) \cr +#' @param object `character(1)` \cr #' The generic function \code{predict} uses a parameter \code{object} to pass a model. #' If the corresponding argument is named differently in your predict function, specify the name. -#' @param data (`character(1)`) \cr +#' @param data `character(1)` \cr #' The generic function \code{predict} uses a parameter \code{data} to pass new data. #' If the corresponding argument is named differently in your predict function, specify the name. -#' @param extract_pred_fct (`character(1) or function(1)`) \cr +#' @param extract_pred_fct `character(1) or function(1)` \cr #' 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 column. -#' @param extract_var_fct (`character(1) or function(1)`) \cr +#' @param extract_var_fct `character(1) or function(1)` \cr #' If the variable selection function that is called 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 selected variables. #' Default value is NULL, if selected variables are in a vector. @@ -93,7 +94,7 @@ createTrainLayer = function (training, lrn_fct, param_train_list = list(), param_pred_list = list(), - na_rm = TRUE, + na_action = "na.rm", x = "x", y = "y", object = "object", @@ -115,7 +116,7 @@ createTrainLayer = function (training, varsel_fct = varsel_fct, varsel_param = varsel_param, train_layer = train_layer, - na_rm = na_rm + na_action = na_action ) var_sel$interface(x = x, y = y, @@ -131,7 +132,7 @@ createTrainLayer = function (training, param_train_list = param_train_list, param_pred_list = param_pred_list, train_layer = train_layer, - na_rm = na_rm + na_action = na_action ) lrner$interface(x = x, y = y, @@ -151,33 +152,33 @@ createTrainLayer = function (training, #' @description #' Creates and store a [TrainMetaLayer] on the [Training] object passed as argument. #' -#' @param training (`Training(1)`) \cr +#' @param training `Training(1)` \cr #' Training object where the created layer will be stored. -#' @param meta_layer_id (`character(1)`) \cr +#' @param meta_layer_id `character(1)` \cr #' ID of the layer to be created. -#' @param lrner_package (`character(1)`) \cr +#' @param lrner_package `character(1)` \cr #' Name of the package containing the function that implements the learning algorithm.\cr -#' @param lrn_fct `(character(1)` \cr +#' @param lrn_fct `character(1)` \cr #' Name of the function that that implements the learning algorithm. -#' @param param_train_list `(character(1)` \cr +#' @param param_train_list `character(1)` \cr #' List of arguments to be passed to \code{lrn_fct}. -#' @param param_pred_list `(character(1)` \cr +#' @param param_pred_list `list(1)` \cr #' List of arguments to be passed to \code{predict} when computing predictions. -#' @param na_action \cr +#' @param na_action `character(1)`\cr #' Handling of missing values in meta-data. Set to "na.keep" to keep missing values, "na.rm" to remove individuals with missing values or "na.impute" 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 meta-learner can handle missing values. -#' @param x (`character(1)`) \cr +#' @param x `character(1)` \cr #' If the name of the argument used by the provided original functions to pass #' the matrix of independent variable is not \code{x}, use this argument to specify how it is callled in the provided function. -#' @param y (`character(1)`) \cr +#' @param y `character(1)` \cr #' If the name of the argument used by the provided original functions to pass #' the target variable is not \code{y}, use this argument to specify how it is callled in the provided function. -#' @param object (`character(1)`) \cr +#' @param object `character(1)` \cr #' The generic function \code{predict} uses a parameter \code{object} to pass a model. #' If the corresponding argument is named differently in your predict function, specify the name. -#' @param data (`character(1)`) \cr +#' @param data `character(1)` \cr #' The generic function \code{predict} uses a parameter \code{data} to pass new data. #' If the corresponding argument is named differently in your predict function, specify the name. -#' @param extract_pred_fct (`character(1) or function(1)`) \cr +#' @param extract_pred_fct `character(1) or function(1)` \cr #' 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. @@ -200,23 +201,6 @@ createTrainMetaLayer = function (training, # Instantiate a layer train_meta_layer = TrainMetaLayer$new(id = meta_layer_id, training = training) - impute = FALSE - # Instantiate a Lrner object - if (na_action == "na.keep") { - na_rm = FALSE - } else { - if (na_action == "na.rm") { - na_rm = TRUE - } else { - if (na_action == "na.impute") { - na_rm = FALSE - impute = TRUE - } else { - stop("na_action must be one of 'na.fails', 'na.rm' or 'na.impute'.") - } - } - } - training$setImpute(impute = impute) meta_lrner = Lrner$new( id = sprintf("%s_lrner", meta_layer_id), package = lrner_package, @@ -224,7 +208,7 @@ createTrainMetaLayer = function (training, param_train_list = param_train_list, param_pred_list = param_pred_list, train_layer = train_meta_layer, - na_rm = na_rm + na_action = na_action ) meta_lrner$interface(x = x, y = y, @@ -238,7 +222,7 @@ createTrainMetaLayer = function (training, #' @description #' Variable selection on the current training object. #' -#' @param training (`Training(1)`) \cr +#' @param training `Training(1)` \cr #' Training object where the created layer will be stored. #' @param ind_subset `vector(1)` \cr #' ID subset of individuals to be used for variable selection. @@ -258,15 +242,15 @@ varSelection = function (training, #' @description #' Trains the [Training] object passed as argument. All leaners and the meta learner are trained. #' -#' @param training (`Training(1)`) \cr +#' @param training `Training(1)` \cr #' Training object where the created layer will be stored. -#' @param ind_subset (`vector(1)`) \cr +#' @param ind_subset `vector(1)` \cr #' ID subset to be used for training. #' @param use_var_sel `boolean(1)` \cr #' If TRUE, variable selection is performed before training. -#' @param resampling_method (`function(1)`) \cr +#' @param resampling_method `function(1)` \cr #' Function for internal validation. If not specify, the \code{resampling} function from the package \code{caret} is used for a 10-folds cross-validation. -#' @param resampling_arg (`list(1)`) \cr +#' @param resampling_arg `list(1)` \cr #' List of arguments to be passed to the function. #' #' @return @@ -291,11 +275,11 @@ fusemlr = function (training, #' @description #' Computes predictions for the [Testing] object passed as argument. #' -#' @param object (`Training(1)`) \cr +#' @param object `Training(1)` \cr #' Training object to be used to compute predictions. -#' @param testing (`Testing(1)`) \cr +#' @param testing `Testing(1)` \cr #' A new testing object to be predicted. -#' @param ind_subset (`vector(1)`) \cr +#' @param ind_subset `vector(1)` \cr #' Vector of IDs to be predicted. #' #' @return @@ -314,7 +298,7 @@ predict.Training = function (object, #' @description #' Extracts models stored on each layers; base and meta models are extracted. #' -#' @param training (`Training(1)`) \cr +#' @param training `Training(1)` \cr #' The [Training] object of interest. #' #' @return @@ -329,7 +313,7 @@ extractModel = function (training) { #' @description #' Extracts data stored on each layers; base and meta data are extracted. #' -#' @param training (`Training(1)`) \cr +#' @param training `Training(1)` \cr #' The [Training] object of interest. #' #' @return @@ -344,7 +328,7 @@ extractData = function (training) { #' @description #' Summaries a fuseMLR [Training] object. #' -#' @param object (`Training(1)`) \cr +#' @param object `Training(1)` \cr #' The [Training] object of interest. #' @param ... \cr #' Further arguments. @@ -359,7 +343,7 @@ summary.Training = function (object, ...) { #' @description #' An upset plot of overlapping individuals. #' -#' @param object (`Training(1) or Testing(1)`) \cr +#' @param object `Training(1) or Testing(1)` \cr #' Training or testing object for each the upset plot will be created. #' @param ... \cr #' Further arguments to be passed to the \code{upset} function from package \code{UpSetR}. diff --git a/README.Rmd b/README.Rmd index ea6d034..fb8272b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -103,7 +103,7 @@ createTrainLayer(training = training, mtry = 1L, na.action = "na.learn"), param_pred_list = list(), - na_rm = FALSE) + na_action = "na.keep") # Create gene protein abundance layer createTrainLayer(training = training, @@ -121,7 +121,7 @@ createTrainLayer(training = training, mtry = 1L, na.action = "na.learn"), param_pred_list = list(), - na_rm = FALSE) + na_action = "na.keep") # Create methylation layer createTrainLayer(training = training, @@ -139,7 +139,7 @@ createTrainLayer(training = training, mtry = 1L, na.action = "na.learn"), param_pred_list = list(), - na_rm = FALSE) + na_action = "na.keep") ``` - Also add a meta layer. @@ -293,7 +293,7 @@ createTrainLayer(training = training, kernel = 'radial', probability = TRUE), param_pred_list = list(probability = TRUE), - na_rm = TRUE, + na_action = "na.keep", x = "x", y = "y", object = "object", diff --git a/man/Lrner.Rd b/man/Lrner.Rd index 00688e0..14f39d6 100644 --- a/man/Lrner.Rd +++ b/man/Lrner.Rd @@ -39,7 +39,7 @@ Initialize a default parameters list. param_train_list, param_pred_list = list(), train_layer, - na_rm = TRUE + na_action = "na.rm" )}\if{html}{\out{}} } @@ -65,8 +65,8 @@ Learn parameters.} \item{\code{train_layer}}{(\code{TrainLayer(1)}) \cr Layer on which the learner is stored.} -\item{\code{na_rm}}{(\code{logical(1)}) \cr -If \code{TRUE}, the individuals with missing predictor values will be removed from the training dataset.} +\item{\code{na_action}}{\code{character(1)}\cr +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.} } \if{html}{\out{}} } diff --git a/man/VarSel.Rd b/man/VarSel.Rd index b9dbfdd..49cd251 100644 --- a/man/VarSel.Rd +++ b/man/VarSel.Rd @@ -37,7 +37,7 @@ Learner ID. varsel_fct, varsel_param, train_layer, - na_rm = TRUE + na_action = "na.rm" )}\if{html}{\out{}} } @@ -61,7 +61,8 @@ Layer on which the learner is stored.} \item{\code{train_layer}}{(\code{TrainLayer(1)}) \cr The training layer where to store the learner.} -\item{\code{na_rm}}{(\code{logical(1)}) \cr +\item{\code{na_action}}{\code{character(1)}\cr +Handling of missing values in meta-data. 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. If \code{TRUE}, the individuals with missing predictor values will be removed from the training dataset.} } \if{html}{\out{}} diff --git a/man/createTrainLayer.Rd b/man/createTrainLayer.Rd index 21607d5..1ffd716 100644 --- a/man/createTrainLayer.Rd +++ b/man/createTrainLayer.Rd @@ -15,7 +15,7 @@ createTrainLayer( lrn_fct, param_train_list = list(), param_pred_list = list(), - na_rm = TRUE, + na_action = "na.rm", x = "x", y = "y", object = "object", @@ -25,61 +25,61 @@ createTrainLayer( ) } \arguments{ -\item{training}{(\code{Training(1)}) \cr +\item{training}{\code{Training} \cr Training object where the created layer will be stored.} -\item{train_layer_id}{(\code{character(1)}) \cr +\item{train_layer_id}{\code{character} \cr ID of the \link{TrainLayer} to be created.} -\item{train_data}{(\code{data.frame(1)}) \cr +\item{train_data}{\code{data.frame(1)} \cr Data modality to be stored in \link{TrainData}.} -\item{varsel_package}{(\code{character(1)}) \cr +\item{varsel_package}{\code{character(1)} \cr Name of the package containing the function that implements the variable selection algorithm.\cr} -\item{varsel_fct}{(\code{character(1)}) \cr +\item{varsel_fct}{\code{character(1)} \cr Name of the function that performs variable selection. For the default value NULL no variable selection will be performed.} -\item{varsel_param}{(\code{list}) \cr +\item{varsel_param}{\code{list} \cr List of arguments to be passed to \code{varsel_fct}.} -\item{lrner_package}{(\code{character(1)}) \cr +\item{lrner_package}{\code{character(1)} \cr Name of the package containing the function that implements the learning algorithm.\cr} -\item{lrn_fct}{\verb{(character(1)} \cr +\item{lrn_fct}{\code{character(1)} \cr Name of the function that that implements the learning algorithm.} -\item{param_train_list}{\verb{(character(1)} \cr +\item{param_train_list}{\code{character(1)} \cr List of arguments to be passed to \code{lrn_fct}.} -\item{param_pred_list}{\verb{(character(1)} \cr +\item{param_pred_list}{\code{character(1)} \cr List of arguments to be passed to \code{predict} when computing predictions.} -\item{na_rm}{\cr -If \code{TRUE}, the individuals with missing predictor values will be removed from the training dataset.} +\item{na_action}{\code{character(1)}\cr +Handling of missing values in data a modality. Set to "na.keep" to keep missing values, or "na.rm" to remove individuals with missing values. Imputation of missing values in data modalities ist not yet handled.} -\item{x}{(\code{character(1)}) \cr +\item{x}{\code{character(1)} \cr If the name of the argument used by the provided original functions to pass the matrix of independent variable is not \code{x}, use this argument to specify how it is callled in the provided function.} -\item{y}{(\code{character(1)}) \cr +\item{y}{\code{character(1)} \cr If the name of the argument used by the provided original functions to pass the target variable is not \code{y}, use this argument to specify how it is callled in the provided function.} -\item{object}{(\code{character(1)}) \cr +\item{object}{\code{character(1)} \cr The generic function \code{predict} uses a parameter \code{object} to pass a model. If the corresponding argument is named differently in your predict function, specify the name.} -\item{data}{(\code{character(1)}) \cr +\item{data}{\code{character(1)} \cr The generic function \code{predict} uses a parameter \code{data} to pass new data. If the corresponding argument is named differently in your predict function, specify the name.} -\item{extract_pred_fct}{(\verb{character(1) or function(1)}) \cr +\item{extract_pred_fct}{\verb{character(1) or function(1)} \cr 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 column.} -\item{extract_var_fct}{(\verb{character(1) or function(1)}) \cr +\item{extract_var_fct}{\verb{character(1) or function(1)} \cr If the variable selection function that is called 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 selected variables. Default value is NULL, if selected variables are in a vector.} diff --git a/man/createTrainMetaLayer.Rd b/man/createTrainMetaLayer.Rd index b2bd331..3d6d980 100644 --- a/man/createTrainMetaLayer.Rd +++ b/man/createTrainMetaLayer.Rd @@ -20,44 +20,44 @@ createTrainMetaLayer( ) } \arguments{ -\item{training}{(\code{Training(1)}) \cr +\item{training}{\code{Training(1)} \cr Training object where the created layer will be stored.} -\item{meta_layer_id}{(\code{character(1)}) \cr +\item{meta_layer_id}{\code{character(1)} \cr ID of the layer to be created.} -\item{lrner_package}{(\code{character(1)}) \cr +\item{lrner_package}{\code{character(1)} \cr Name of the package containing the function that implements the learning algorithm.\cr} -\item{lrn_fct}{\verb{(character(1)} \cr +\item{lrn_fct}{\code{character(1)} \cr Name of the function that that implements the learning algorithm.} -\item{param_train_list}{\verb{(character(1)} \cr +\item{param_train_list}{\code{character(1)} \cr List of arguments to be passed to \code{lrn_fct}.} -\item{param_pred_list}{\verb{(character(1)} \cr +\item{param_pred_list}{\code{list(1)} \cr List of arguments to be passed to \code{predict} when computing predictions.} -\item{na_action}{\cr +\item{na_action}{\code{character(1)}\cr Handling of missing values in meta-data. Set to "na.keep" to keep missing values, "na.rm" to remove individuals with missing values or "na.impute" 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 meta-learner can handle missing values.} -\item{x}{(\code{character(1)}) \cr +\item{x}{\code{character(1)} \cr If the name of the argument used by the provided original functions to pass the matrix of independent variable is not \code{x}, use this argument to specify how it is callled in the provided function.} -\item{y}{(\code{character(1)}) \cr +\item{y}{\code{character(1)} \cr If the name of the argument used by the provided original functions to pass the target variable is not \code{y}, use this argument to specify how it is callled in the provided function.} -\item{object}{(\code{character(1)}) \cr +\item{object}{\code{character(1)} \cr The generic function \code{predict} uses a parameter \code{object} to pass a model. If the corresponding argument is named differently in your predict function, specify the name.} -\item{data}{(\code{character(1)}) \cr +\item{data}{\code{character(1)} \cr The generic function \code{predict} uses a parameter \code{data} to pass new data. If the corresponding argument is named differently in your predict function, specify the name.} -\item{extract_pred_fct}{(\verb{character(1) or function(1)}) \cr +\item{extract_pred_fct}{\verb{character(1) or function(1)} \cr 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.} diff --git a/man/createTraining.Rd b/man/createTraining.Rd index 53050db..277d068 100644 --- a/man/createTraining.Rd +++ b/man/createTraining.Rd @@ -6,29 +6,30 @@ \usage{ createTraining( id, + target_df, ind_col, target, - target_df, problem_type = "classification", verbose = TRUE ) } \arguments{ -\item{id}{(\code{character(1)}) \cr} +\item{id}{\code{character} \cr +Training's ID.} -\item{ind_col}{(\code{character(1)}) \cr -Name of column of individuals IDS.} +\item{target_df}{\code{data.frame} \cr +Observed target values. A data frame with two columns: individual IDs and response variable values.} -\item{target}{(\code{character(1)}) \cr -Name of the target variable.} +\item{ind_col}{\code{character} \cr +Name of column of individuals IDs.} -\item{target_df}{(\code{data.frame(1)}) \cr -Data frame with two columns: individual IDs and response variable values.} +\item{target}{\code{character} \cr +Name of the target variable.} -\item{problem_type}{(\code{character}) \cr +\item{problem_type}{\code{character} \cr Either "classification" or "regression".} -\item{verbose}{(\code{boolean}) \cr +\item{verbose}{\code{boolean} \cr Warning messages will be displayed if set to TRUE.} } \value{ diff --git a/man/extractData.Rd b/man/extractData.Rd index f695a37..2594c54 100644 --- a/man/extractData.Rd +++ b/man/extractData.Rd @@ -7,7 +7,7 @@ extractData(training) } \arguments{ -\item{training}{(\code{Training(1)}) \cr +\item{training}{\code{Training(1)} \cr The \link{Training} object of interest.} } \value{ diff --git a/man/fusemlr.Rd b/man/fusemlr.Rd index c6af1f0..9a45651 100644 --- a/man/fusemlr.Rd +++ b/man/fusemlr.Rd @@ -13,19 +13,19 @@ fusemlr( ) } \arguments{ -\item{training}{(\code{Training(1)}) \cr +\item{training}{\code{Training(1)} \cr Training object where the created layer will be stored.} -\item{ind_subset}{(\code{vector(1)}) \cr +\item{ind_subset}{\code{vector(1)} \cr ID subset to be used for training.} \item{use_var_sel}{\code{boolean(1)} \cr If TRUE, variable selection is performed before training.} -\item{resampling_method}{(\verb{function(1)}) \cr +\item{resampling_method}{\verb{function(1)} \cr Function for internal validation. If not specify, the \code{resampling} function from the package \code{caret} is used for a 10-folds cross-validation.} -\item{resampling_arg}{(\code{list(1)}) \cr +\item{resampling_arg}{\code{list(1)} \cr List of arguments to be passed to the function.} } \value{ diff --git a/man/predict.Training.Rd b/man/predict.Training.Rd index f3dece4..4b9473b 100644 --- a/man/predict.Training.Rd +++ b/man/predict.Training.Rd @@ -7,13 +7,13 @@ \method{predict}{Training}(object, testing, ind_subset = NULL) } \arguments{ -\item{object}{(\code{Training(1)}) \cr +\item{object}{\code{Training(1)} \cr Training object to be used to compute predictions.} -\item{testing}{(\code{Testing(1)}) \cr +\item{testing}{\code{Testing(1)} \cr A new testing object to be predicted.} -\item{ind_subset}{(\code{vector(1)}) \cr +\item{ind_subset}{\code{vector(1)} \cr Vector of IDs to be predicted.} } \value{ diff --git a/man/summary.Training.Rd b/man/summary.Training.Rd index 384e04d..10cb353 100644 --- a/man/summary.Training.Rd +++ b/man/summary.Training.Rd @@ -7,7 +7,7 @@ \method{summary}{Training}(object, ...) } \arguments{ -\item{object}{(\code{Training(1)}) \cr +\item{object}{\code{Training(1)} \cr The \link{Training} object of interest.} \item{...}{\cr diff --git a/man/upsetplot.Rd b/man/upsetplot.Rd index 862fd2d..4c66ec4 100644 --- a/man/upsetplot.Rd +++ b/man/upsetplot.Rd @@ -7,7 +7,7 @@ upsetplot(object, ...) } \arguments{ -\item{object}{(\verb{Training(1) or Testing(1)}) \cr +\item{object}{\verb{Training(1) or Testing(1)} \cr Training or testing object for each the upset plot will be created.} \item{...}{\cr diff --git a/man/varSelection.Rd b/man/varSelection.Rd index e88f124..a1df063 100644 --- a/man/varSelection.Rd +++ b/man/varSelection.Rd @@ -7,7 +7,7 @@ varSelection(training, ind_subset = NULL) } \arguments{ -\item{training}{(\code{Training(1)}) \cr +\item{training}{\code{Training(1)} \cr Training object where the created layer will be stored.} \item{ind_subset}{\code{vector(1)} \cr diff --git a/tests/testthat/test-Training.R b/tests/testthat/test-Training.R index b3128e5..1791704 100644 --- a/tests/testthat/test-Training.R +++ b/tests/testthat/test-Training.R @@ -176,7 +176,7 @@ test_that("Training: all tests", { lrner_meta <- Lrner$new(id = "weighted", lrn_fct = "weightedMeanLearner", param_train_list = list(), - na_rm = FALSE, + na_action = "na.keep", train_layer = tl_meta) }) diff --git a/vignettes/how_to_use.Rmd b/vignettes/how_to_use.Rmd index f1c88ac..62792f4 100644 --- a/vignettes/how_to_use.Rmd +++ b/vignettes/how_to_use.Rmd @@ -77,7 +77,7 @@ createTrainLayer(training = training, mtry = 1L, na.action = "na.learn"), param_pred_list = list(), - na_rm = TRUE) + na_action = "na.keep") # Create gene protein abundance layer createTrainLayer(training = training, @@ -95,7 +95,7 @@ createTrainLayer(training = training, mtry = 1L, na.action = "na.learn"), param_pred_list = list(type = "response"), - na_rm = TRUE) + na_action = "na.keep") # Create methylation layer createTrainLayer(training = training, @@ -113,7 +113,7 @@ createTrainLayer(training = training, mtry = 1L, na.action = "na.learn"), param_pred_list = list(), - na_rm = TRUE) + na_action = "na.keep") ``` Also add a meta layer. @@ -264,7 +264,7 @@ createTrainLayer(training = training, kernel = 'radial', probability = TRUE), param_pred_list = list(probability = TRUE), - na_rm = TRUE, + na_action = "na.rm"), x = "x", y = "y", object = "object",