model: model class

Description Usage Arguments Value predicted slot seq_in slot Examples

View source: R/model_class.R

Description

A class for models that can be trained/applied to datasets e.g. PCA, PLS etc. Also used for preprocessing steps that require application to test sets. not intended to be called directly, this class should be inherited to provide functionality for method-specific classes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
model(
  predicted = character(0),
  seq_in = "data",
  seq_fcn = function(x) {     return(x) },
  ...
)

## S4 method for signature 'model,DatasetExperiment'
model_train(M, D)

## S4 method for signature 'model,DatasetExperiment'
model_predict(M, D)

## S4 method for signature 'model,DatasetExperiment'
model_apply(M, D)

## S4 method for signature 'model,DatasetExperiment'
model_reverse(M, D)

## S4 method for signature 'model'
predicted(M)

## S4 method for signature 'model'
seq_in(M)

## S4 replacement method for signature 'model,character'
seq_in(M) <- value

## S4 method for signature 'model'
predicted_name(M)

## S4 replacement method for signature 'model,character'
predicted_name(M) <- value

Arguments

predicted

The name of an output slot to return when using predicted() (see details)

seq_in

the name of an output slot to connect with the "predicted" output of another model (see details)

seq_fcn

a function to apply to seq_in before inputting into the next model. Typically used to extract a single column, or convert from factor to char etc.

...

named slots and their values.

M

A struct model object

D

A DatasetExperiment object

value

The value to assign

Value

trained model object

model object with test set results

trained model object

dataset dataset object with the reverse model applied

the predicted output, as specified by predicted_name

the id of the input parameter to be replaced by the predicted output of the previous model in a model sequence. Reserved keyword 'data' means that the input data used by model_train, model_apply etc is used. seq_in = 'data' is the default setting.

the modified model object

the id of the output returned by predicted()

the modified model object

predicted slot

The "predicted" slot is a slots for use by users to control the flow of model sequences. The predicted() function is used to return a default output and from a model. Typically it is a DatasetExperiment object that is passed directly into the next model in a sequence as the data for that model.

seq_in slot

In a sequence of models (see model_seq) the "predicted" slot is connected to the DatasetExperiment input of the next model. seq_in can be used to control flow and connect the "predicted" output to the input parameter of the next model. Default is the keyword 'data', and can otherwise be replaced by any input slot from the model. The slot seq_fcn can be used to apply a transformation to the output before it is used as an input. This allows you to e.g. convert between types, extract a single column from a data.frame etc.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
M = model()
D = DatasetExperiment()
M = model()
M = model_train(M,D)
D = DatasetExperiment()
M = model()
M = model_train(M,D)
M = model_predict(M,D)
D = DatasetExperiment()
M = model()
M = model_apply(M,D)
D = DatasetExperiment()
M = model()
M = model_train(M,D)
M = model_predict(M,D)
M = model_reverse(M,D)
D = DatasetExperiment()
M = example_model()
M = model_train(M,D)
M = model_predict(M,D)
p = predicted(M)
D = DatasetExperiment()
M = example_model()
seq_in(M) = 'data'
M = example_model()
seq_in(M) = 'value_1'
M = example_model()
predicted_name(M)
M = example_model()
predicted_name(M) = 'result_2'

struct documentation built on Nov. 8, 2020, 8:14 p.m.