| dfr_mcdd | R Documentation |
MCDD is a window-based detector that compares the location of a reference and a recent sample by means of a hypothesis test on their central tendency. Because it monitors the distribution of an observed feature rather than predictive errors, it is primarily intended for virtual concept drift. In this package, the detector follows the statistical-testing perspective adopted by Giusti et al. (2021) for drift analysis.
dfr_mcdd(
target_feat = NULL,
alpha = 1e-04,
normality_alpha = 0.05,
window_size = 300,
window_type = "sliding",
monitoring_step = 1,
data = NULL
)
target_feat |
Feature to be monitored |
alpha |
Probability threshold for the comparison test |
normality_alpha |
Significance level of the Shapiro-Wilk normality test used to decide between the parametric and the nonparametric comparison. It is deliberately separate from |
window_size |
Size of the window |
window_type |
Window policy. |
monitoring_step |
Number of observations between two consecutive tests. The default ( |
data |
Already collected data to avoid cold start. |
MCDD only reacts to changes of location (mean or median); a change of
spread with the same centre is not detected, so combine it with dfr_lbdd()
when both kinds of change matter.
Normality of both halves of the window is checked with
stats::shapiro.test(); when it holds, a t-test is applied, otherwise a
Wilcoxon rank-sum test is used. Shapiro-Wilk is only defined for samples of at
most 5000 observations, so larger windows always fall back to the
nonparametric test.
Missing observations are skipped instead of being imputed.
dfr_mcdd object
Giusti, L., Carvalho, L., Gomes, A. T., Coutinho, R., Soares, J., and Ogasawara, E. (2021). Analysing flight delay under concept drift. Evolving Systems. doi:10.1007/s12530-021-09415-z
# Load Heimdall and the synthetic stream.
library(heimdall)
# Fix the seed to keep the walkthrough reproducible.
seed <- 1
set.seed(seed)
# Load the univariate series monitored in this example.
data(st_drift_examples)
serie <- st_drift_examples$uv_virtual_drift
# Plot the monitored signal before running the detector.
plot(x=seq_len(nrow(serie)), y=serie$serie)
# Instantiate the mean-comparison detector.
model <- dfr_mcdd(target_feat='serie', window_size=100)
# Update the detector sequentially and collect the alarm positions.
detection <- NULL
output <- list(obj=model, drift=FALSE)
for (i in seq_len(nrow(serie))){
output <- update_state(output$obj, serie$serie[i])
if (output$drift){
type <- 'drift'
output$obj <- reset_state(output$obj)
} else {
type <- ''
}
detection <- rbind(detection, data.frame(idx=i, event=output$drift, type=type))
}
# Print the detected drift points.
detection[detection$type == 'drift',]
# Overlay the detected drifts on the original series.
plot(x=seq_len(nrow(serie)), y=serie$serie)
for (drift_index in detection[detection$type == 'drift', 'idx']) {
abline(v=drift_index, col='red', lty=2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.