adp_recurrent: Recurrent-concept adaptive model

View source: R/ac_remind.R

adp_recurrentR Documentation

Recurrent-concept adaptive model

Description

Drift-adaptive classifier with concept management (the model formerly named REMIND). A concept holds a model, its preprocessors (one-hot and normalization), a data memory and a decision threshold. At every labeled batch, fit() runs the drift detector, lets the concept_pool keep, reuse or create a concept, and trains the active concept. predict() answers with the active concept or, with check, with the concept chosen from the batch features alone.

A batch is usable when at least 1% of its rows are positive. A drift on a non-usable batch postpones the adaptation: the batch only enters the data windows.

Usage

adp_recurrent(
  method,
  drift_method,
  model_manager = concept_pool_inactive(),
  memory = memory_basic(),
  trainer = train_static(),
  train_size,
  th = NULL,
  check = NULL,
  warmup_size = 100,
  rare_policy = rare_keep(),
  record_policy = rec_stable(),
  check_rank = rank_ratio(),
  preprocess = NULL,
  verbose = FALSE
)

Arguments

method

Classifier used by every concept (e.g. torch_cla_mlp).

drift_method

Drift detector.

model_manager

Concept concept_pool: concept_pool() stores and reuses concepts; concept_pool_inactive() never reuses them (every drift creates a new concept).

memory

Memory prototype: stores the data window of each concept and balances the training data of every full training (first training and retrain).

trainer

Training activity: how a concept's model evolves after its first (full) training (a variation point of the line). A model_trainer() object: train_static() (default; frozen), train_retrain() (retrained from scratch on the concept memory at every batch) or train_incremental() (updated with the current batch only, keeping weights and preprocessing).

train_size

Number of rows needed to train a new concept. It is also the size of the sliding windows: the buffer of recent rows and the memory of each concept.

th

Decision threshold. NULL (default): each concept uses the threshold in {0.05, ..., 0.95} with the highest F1 on its own memory, recomputed when its model or data change. A number fixes the threshold for every concept.

check

NULL (default) disables the check. A slct_psi() object enables it: predict() picks, from the batch features only, the concept with the smallest ratio between its PSI and its limit; fit() records the PSI of each labeled batch in the check history of the active concept. The limit is the fixed max_psi of the object or, when NULL, learned from the check history (quantile tol_quantile). Uses also the n_tiles and numerical_cols of the object.

warmup_size

Minimum number of rows to train a model, to run the drift detector and to apply the check.

rare_policy

Admission activity for labeled batches with < 1% positives (an optional activity of the line). A rare_policy() object: rare_keep() (default, neutral; the batch is used and only the drift adaptation is postponed) or rare_drop() (the batch is ignored).

record_policy

Recording activity: which labeled batches enter the learned limits (an optional activity of the line). A record_policy() object: rec_stable() (default; a batch flagged by a real detector does not record, but a passive detector never blocks it) or rec_always() (neutral; every batch that reaches the concept pool records, used in the experiments).

check_rank

How the check picks the concept (a variation point of the line). A concept_ranker() object: rank_ratio() (default; smallest PSI/limit) or rank_psi() (smallest PSI). Both pick a concept even above its limit (no new concept at predict time).

preprocess

Preprocessing of each concept: a trans_pipeline() (or any fitted-able dal_transform) applied to the features before the model. NULL (default) uses trans_pipeline(list(one_hot(), zscore())) (one-hot encoding then z-score normalization). Pass another sequence to change or drop steps.

verbose

If TRUE, prints drift messages.

Value

A adp_recurrent object. After each fit() it exposes drifted, trained, postponed, dropped, act_concept and the times time_drifter, time_adaptation, time_training, time_threshold and total_time.

Examples

## Not run: 
library(daltoolboxdp)
model <- adp_recurrent(
 method = torch_cla_mlp("class", c("FALSE", "TRUE"), input_size = 10, hidden_sizes = 32L),
 drift_method = dfr_passive(),
 model_manager = concept_pool(slct_psi(n_tiles = 5), evt_least_used(), n_slots = 20),
 memory = memory_undersampling(),
 trainer = train_incremental(epochs = 5),
 train_size = 5000,
 check = slct_psi(n_tiles = 5, tol_quantile = 0.8)
)

## End(Not run)

heimdall documentation built on Dec. 2, 2026, 5:08 p.m.