Manages long-lived memory cells that can be recalled when distribution shifts are detected. Implements the immunological distinction between short-lived effector cells and long-lived memory cells.
Public fields
memory_cellsNumeric matrix of archived memory antibodies.
memory_metadataData frame of metadata for memory cells.
archive_thresholdAffinity threshold for archiving (only high-quality antibodies become memory).
max_memoryMaximum number of memory cells to store.
recall_thresholdThreshold for triggering memory recall.
Methods
Method new()
Create a new MemoryPool.
Usage
MemoryPool$new(
archive_threshold = 0.5,
max_memory = 100,
recall_threshold = 0.3
)Method archive()
Archive high-performing antibodies as memory cells.
Usage
MemoryPool$archive(
repertoire,
X,
affinityFunc = "gaussian",
affinityParams = list(alpha = 1, c = 1, p = 2)
)Arguments
repertoireAn
ImmuneRepertoire.XTraining data matrix.
affinityFuncCharacter. Affinity function.
affinityParamsList. Affinity parameters.
Method recall()
Recall memory cells relevant to current data.
Usage
MemoryPool$recall(
X,
affinityFunc = "gaussian",
affinityParams = list(alpha = 1, c = 1, p = 2)
)Examples
# Archive and recall memory cells
data(iris)
X <- as.matrix(iris[, 1:4])
A <- X[sample(150, 10), ]
mp <- MemoryPool$new(archive_threshold = 0.01)
rep <- ImmuneRepertoire$new(A)
mp$archive(rep, X)
#> [1] 10
mp$size() # number of archived memories
#> [1] 10
recalled <- mp$recall(X[1:5, ])
nrow(recalled) # memories relevant to query
#> [1] 5
