| DDM | R Documentation |
Implements the Drift Detection Method (DDM), used for detecting concept drift in data streams by analyzing the performance of online learners. The method monitors changes in the error rate of a learner, signaling potential concept drift.
DDM is designed to be simple yet effective for detecting concept drift by monitoring the error rate of any online classifier. The method is particularly sensitive to increases in the error rate, which is typically a strong indicator of concept drift.
min_instancesMinimum number of instances required before drift detection begins.
warning_levelMultiplier for the standard deviation to set the warning threshold.
out_control_levelMultiplier for the standard deviation to set the out-of-control threshold.
sample_countCounter for the number of samples processed.
miss_probCurrent estimated probability of misclassification.
miss_stdCurrent estimated standard deviation of misclassification probability.
miss_prob_sd_minMinimum recorded value of misclassification probability plus its standard deviation.
miss_prob_minMinimum recorded misclassification probability.
miss_sd_minMinimum recorded standard deviation.
estimationCurrent estimation of misclassification probability.
change_detectedBoolean indicating if a drift has been detected.
warning_detectedBoolean indicating if a warning level has been reached.
delayDelay since the last relevant sample.
new()Initializes the DDM detector with specific parameters.
DDM$new(min_num_instances = 30, warning_level = 2, out_control_level = 3)
min_num_instancesMinimum number of samples required before starting drift detection.
warning_levelThreshold multiplier for setting a warning level.
out_control_levelThreshold multiplier for setting the out-of-control level.
reset()Resets the internal state of the DDM detector.
DDM$reset()
add_element()Adds a new prediction error value to the model, updates the calculation of the misclassification probability and its standard deviation, and checks for warnings or drifts based on updated statistics.
DDM$add_element(prediction)
predictionThe new data point (prediction error) to be added to the model.
detected_change()Returns a boolean indicating whether a drift has been detected based on the monitored statistics.
DDM$detected_change()
clone()The objects of this class are cloneable with this method.
DDM$clone(deep = FALSE)
deepWhether to make a deep clone.
João Gama, Pedro Medas, Gladys Castillo, Pedro Pereira Rodrigues: Learning with Drift Detection. SBIA 2004: 286-295
Implementation: https://github.com/scikit-multiflow/scikit-multiflow/blob/a7e316d1cc79988a6df40da35312e00f6c4eabb2/src/skmultiflow/drift_detection/ddm.py
set.seed(123) # Setting a seed for reproducibility
data_part1 <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.7, 0.3))
# Introduce a change in data distribution
data_part2 <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.3, 0.7))
# Combine the two parts
data_stream <- c(data_part1, data_part2)
ddm <- DDM$new()
# Iterate through the data stream
for (i in seq_along(data_stream)) {
ddm$add_element(data_stream[i])
if (ddm$change_detected) {
message(paste("Drift detected!", i))
} else if (ddm$warning_detected) {
# message(paste("Warning detected at position:", i))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.