| dfr_psi | R Documentation |
Monitors a stream with the Population Stability Index
(psi()): the first n_reference observations form the baseline, and every
later window of window_size observations is compared with it, feature by
feature. Since it monitors the distribution of the observed features, it is
primarily used for virtual concept drift, and fits the paper's setting
of validating the fields of incoming data files against a baseline file.
dfr_psi(
target_feat = NULL,
n_reference = 1000,
window_size = 1000,
bins = 10,
threshold = 0.25
)
target_feat |
Names of the columns to be monitored. |
n_reference |
Size of the baseline. |
window_size |
Size of the compared windows (non-overlapping). |
bins |
Number of quantile groups of the baseline (10 for deciles, 20 for demi-deciles). |
threshold |
A drift is reported when the PSI of some feature exceeds
it. The default, 0.25, is the paper's limit of a significant drift; 0.1 also
flags the moderate ones. See |
A drift is reported on the last observation of every window whose
largest PSI exceeds threshold. reset_state() forgets the baseline, and the
next n_reference observations form a new one. Missing values are kept: in
the windows they count as observations in no bin (see psi()).
dfr_psi object. After fit(), drifter_output holds the PSI of
every feature (psi_<feature>) on the last observation of every window, and
obj$reference the baseline.
Kurian, J. F. and Allali, M. (2024). Detecting drifts in data streams using Kullback-Leibler (KL) divergence measure for data engineering applications. Journal of Data, Information and Management, 6, 207-216. doi:10.1007/s42488-024-00119-y
library(daltoolbox)
library(heimdall)
# Scores around 610; from row 3001 half of those above 643 drop by 200.
set.seed(1)
score <- stats::rnorm(5000, 610, 50)
late <- 3001:5000
drop <- late[score[late] > 643 & stats::runif(2000) < 0.5]
score[drop] <- score[drop] - 200
# The PSI reaches about 0.2: a moderate drift, flagged with threshold 0.1.
detector <- dfr_psi(n_reference = 2000, window_size = 500, threshold = 0.1)
model <- fit(detector, data.frame(cbm = score))
model$drifter_output[!is.na(model$drifter_output$psi_cbm), , drop = FALSE]
model$drifted
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.