model {struct} | R Documentation

## model class

### 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

    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'
    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 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

    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)
    M = example_model()
    predicted_name(M)
    M = example_model()
    predicted_name(M) = 'result_2'

[Package struct version 0.99.9 Index]