Training: Training Class

TrainingR Documentation

Training Class

Description

This is a primary classes of fuseMLR. An object from this class is designed to contain multiple training layers, but only one meta training layer.

The Training class is structured as followed:

  • TrainLayer: Specific layer containing:

    • Lrner: Specific learner. This must be set by the user.

    • TrainData: Specific training dataset. This must be set up by the user.

    • Model: Specific model. This is set up by training the learner on the training data.

  • TrainMetaLayer: Basically a TrainLayer, but with some specific properties.

    • Lrner: This is the meta learner, it must be set up by the user.

    • TrainData: Specific modality-specific prediction data. This is set up internally after cross-validation.

    • Model: Specific meta model. This is set up by training the learner on the training data.

Use the function train for training and predict for predicting.

Super class

fuseMLR::HashTable -> Training

Methods

Public methods

Inherited methods

Method new()

constructor

Usage
Training$new(
  id,
  ind_col,
  target,
  target_df,
  problem_type = "classification",
  verbose = TRUE
)
Arguments
id

character

ind_col

character
Name of column of individuals IDS.

target

character
Name of the target variable.

target_df

data.frame
Data frame with two columns: individual IDs and response variable values.

problem_type

character
Either "classification" or "regression".

verbose

boolean
Warning messages will be displayed if set to TRUE.


Method print()

Printer

Usage
Training$print(...)
Arguments
...

any


Method trainLayer()

Train each layer of the current Training.

Usage
Training$trainLayer(ind_subset = NULL, use_var_sel = FALSE, verbose = TRUE)
Arguments
ind_subset

character
Subset of individuals IDs to be used for training.

use_var_sel

boolean
If TRUE, selected variables available at each layer are used.

verbose

boolean
Warning messages will be displayed if set to TRUE.

Returns

Returns the object itself, with a model for each layer.


Method predictLayer()

Predicts values given new data.

Usage
Training$predictLayer(testing, ind_subset = NULL)
Arguments
testing

TestData
Object of class TestData.

ind_subset

vector
Subset of individuals IDs to be used for training.

Returns

A new Training with predicted values for each layer.


Method createMetaTrainData()

Creates a meta training dataset and assigns it to the meta layer.

Usage
Training$createMetaTrainData(
  resampling_method,
  resampling_arg,
  use_var_sel,
  impute = TRUE
)
Arguments
resampling_method

function
Function for internal validation.

resampling_arg

list
List of arguments to be passed to the function.

use_var_sel

boolean
If TRUE, selected variables available at each layer are used.

impute

boolean
If TRUE, mode or median based imputation is performed on the modality-specific predictions.

Returns

The current object is returned, with a meta training dataset assigned to the meta layer.


Method train()

Trains the current object. All leaners and the meta learner are trained.

Usage
Training$train(
  ind_subset = NULL,
  use_var_sel = FALSE,
  resampling_method = NULL,
  resampling_arg = list(),
  seed = NULL
)
Arguments
ind_subset

vector
ID subset to be used for training.

use_var_sel

boolean
If TRUE, variable selection is performed before training.

resampling_method

function
Function for internal validation. If not specify, the resampling function from the package caret is used for a 10-folds cross-validation.

resampling_arg

list
List of arguments to be passed to the function.

seed

integer
Random seed. Default is NULL, which generates the seed from R.

Returns

The current object is returned, with each learner trained on each layer.


Method predict()

Compute predictions for a testing object.

Usage
Training$predict(testing, ind_subset = NULL)
Arguments
testing

Testing
A new testing object to be predicted.

ind_subset

vector
Vector of IDs to be predicted.

Returns

The predicted object. All layers and the meta layer are predicted. This is the final predicted object.


Method varSelection()

Variable selection on the current training object.

Usage
Training$varSelection(ind_subset = NULL, verbose = TRUE)
Arguments
ind_subset

vector
ID subset of individuals to be used for variable selection.

verbose

boolean
Warning messages will be displayed if set to TRUE.

Returns

The current layer is returned with the resulting model.


Method getTargetValues()

Gather target values from all layer.

Usage
Training$getTargetValues()
Returns

A data.frame containing individuals IDs and corresponding target values.


Method getIndIDs()

Gather individual IDs from all layer.

Usage
Training$getIndIDs()
Returns

A data.frame containing individuals IDs.


Method getLayer()

Get a layer of a given ID.

Usage
Training$getLayer(id)
Arguments
id

character
The ID of the layer to be returned.

Returns

The TrainLayer object is returned for the given ID.


Method getTrainMetaLayer()

Getter of the meta layer.

Usage
Training$getTrainMetaLayer()
Returns

Object from class TrainMetaLayer


Method getModel()

Retrieve models from all layer.

Usage
Training$getModel()
Returns

A list containing all (base and meta) models.


Method getData()

Retrieve modality-specific predictions.

Usage
Training$getData()
Returns

A list containing all (base and meta) models.


Method removeLayer()

Remove a layer of a given ID.

Usage
Training$removeLayer(id)
Arguments
id

character
The ID of the layer to be removed.

Returns

The TrainLayer object is returned for the given ID.


Method removeTrainMetaLayer()

Remove the meta layer from the current Training object.

Usage
Training$removeTrainMetaLayer()

Method getIndCol()

Getter of the individual column name.

Usage
Training$getIndCol()

Method getTarget()

Getter of the target variable name.

Usage
Training$getTarget()

Method getVerbose()

Getter of the verbose setting.

Usage
Training$getVerbose()

Method getUseVarSel()

Getter of the use_var_sel field.

Usage
Training$getUseVarSel()

Method getVarSelDone()

Getter of the use_var_sel field.

Usage
Training$getVarSelDone()

Method increaseNbTrainedLayer()

Increase the number of trained layer.

Usage
Training$increaseNbTrainedLayer()

Method checkTargetExist()

Check whether a target object has already been stored.

Usage
Training$checkTargetExist()
Returns

Boolean value


Method getTargetObj()

Getter of the target object.

Usage
Training$getTargetObj()

Method getProblemTyp()

Getter of the problem type.

Usage
Training$getProblemTyp()

Method setImpute()

Set imputation action na.action.

Usage
Training$setImpute(impute)
Arguments
impute

character
How to handle missing values.


Method testOverlap()

Test that individuals overlap over layers. At least five individuals must overlapped.

Usage
Training$testOverlap()

Method upset()

UpSet plot to show an overview of the overlap of individuals across various layers.

Usage
Training$upset(...)
Arguments
...

any
Further parameters to be passed to the upset function from package UpSetR.


Method summary()

Generate training summary

Usage
Training$summary()

See Also

TrainLayer

Testing and Predicting


fuseMLR documentation built on April 3, 2025, 8:49 p.m.