Skip to contents

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

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 target vector (factor or numeric).

task

Character: "clustering", "classification", or "regression".

...

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 print()

Print summary of the algorithm.

Usage

ImmuneAlgorithm$print(...)

Arguments

...

Not used.


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)