Skip to contents

Abstract R6 base class for all immune-inspired algorithms. Subclasses must implement the fit method.

Value

An R6Class generator. ImmuneAlgorithm$new() returns an ImmuneAlgorithm object. It is an abstract base class: use AINet for a fitted model.

Public fields

repertoire

An ImmuneRepertoire object.

config

Named list of algorithm hyperparameters.

modules

Named list of injected module instances (SHMEngine, IdiotypicNetwork, GerminalCenter, etc.).

history

List of per-iteration metrics.

result

The result from the last call to fit().

Methods


Method new()

Create a new ImmuneAlgorithm.

Usage

ImmuneAlgorithm$new(config = list(), modules = list())

Arguments

config

Named list of hyperparameters.

modules

Named list of module instances.


Method fit()

Fit the algorithm to data. Must be overridden by subclasses.

Usage

ImmuneAlgorithm$fit(X, y = NULL, task = NULL, ...)

Arguments

X

Numeric matrix (n x d).

y

Optional factor target for classification.

task

Character: "clustering" or "classification".

...

Additional arguments.

Returns

The algorithm object (invisibly), with result populated.


Method predict()

Predict on new data using the trained repertoire.

Usage

ImmuneAlgorithm$predict(newdata)

Arguments

newdata

Numeric matrix (n_new x d).

Returns

Predictions (class labels, numeric values, or cluster IDs).


Method format()

Format a short summary, one element per line. Used by print().

Usage

ImmuneAlgorithm$format(...)

Arguments

...

Not used.

Returns

A character vector.


Method summary()

Get a summary of the fitting history.

Usage

ImmuneAlgorithm$summary()

Returns

Data frame of per-iteration metrics.


Method clone()

The objects of this class are cloneable with this method.

Usage

ImmuneAlgorithm$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# ImmuneAlgorithm is abstract; use AINet for concrete instances
algo <- ImmuneAlgorithm$new()
print(algo)
#> <ImmuneAlgorithm>
#>   (not yet fitted)