| dfr_studd | R Documentation |
Unsupervised drift detector of Cerqueira, Gomes, Bifet and
Torgo (2023). A classifier (the teacher) is trained on an initial window of
window_size labelled observations, and a second classifier (the student)
is trained on the same observations to mimic the teacher, with the
teacher's predictions as its target. After that no label is used: every new
observation is predicted by both models, and the mimicking error (1 when
the student disagrees with the teacher, 0 otherwise) feeds a change
detector, by default the Page-Hinkley test. When the detector raises an
alarm, the labels of the last window_size observations are requested to
retrain the teacher, and the student is retrained on the new teacher's
predictions. Since the mimicking error does not depend on the labels, it is
used for virtual concept drift.
dfr_studd(
teacher,
student = teacher,
detector = dfr_page_hinkley(delta = 0.001),
window_size = 500,
student_memory = "all",
fit_teacher = TRUE,
target_feat = NULL,
seed = NULL
)
teacher |
A |
student |
A |
detector |
Univariate detector fed with the mimicking errors (a
|
window_size |
Number of observations of the initial training window
and of the window of labels requested after every drift ( |
student_memory |
Observations used to retrain the student after a
drift: |
fit_teacher |
If |
target_feat |
Names of the feature columns. |
seed |
Seed of the random number generator used when the models are
trained. |
Labels are read only for the rows used to (re)train the teacher;
every other row may have a missing label. The initial window is used only
for training: no drift is checked on it. The rows of a drift alarm are
included in the window used to retrain the teacher, as in the reference
implementation (https://github.com/vcerqueira/experiments-studd, studd_batch.py).
A model is always trained on the classes present in its training data, so
that, as in scikit-learn, a class missing from a window does not stop the
training. When a single class is present, the model predicts that class.
Predictions are the class of highest probability (the first one in case of
ties). reset_state() resets the detector and keeps the models.
dfr_studd object. After fit(), drifter_output holds, for every
monitored row, the class predicted by the teacher (teacher) and by the
student (student), the mimicking error (error) and the detector
statistic (statistic), and whether a drift was reported (drift). The
classes are given by their position in the levels of the teacher.
obj$labels_used counts the labels used to train the teacher.
Cerqueira, V., Gomes, H. M., Bifet, A. and Torgo, L. (2023). STUDD: a student-teacher method for unsupervised concept drift detection. Machine Learning, 112, 4351-4378. doi:10.1007/s10994-022-06188-7
library(daltoolbox)
library(heimdall)
set.seed(1)
# Two classes separated by x1 + x2 = 0; from row 1201 on, the observations
# concentrate along the class boundary, where the student imitates the
# teacher worse.
n <- 2400
x <- matrix(stats::rnorm(n * 2), ncol = 2)
x[1201:n, 2] <- -x[1201:n, 1] + stats::rnorm(1200, 0, 0.2)
y <- ifelse(x[, 1] + x[, 2] > 0, "a", "b")
stream <- data.frame(x1 = x[, 1], x2 = x[, 2], class = y)
teacher <- cla_rf("class", c("a", "b"), ntree = 20)
detector <- dfr_studd(teacher, window_size = 400, seed = 1)
model <- fit(detector, stream)
which(model$drifter_output$drift == 1)
model$labels_used
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.