| EDDM {datadriftR} | R Documentation |
EDDM (Early Drift Detection Method)
Description
This class implements the Early Drift Detection Method (EDDM), designed to detect concept drifts in online learning scenarios by monitoring the distances between consecutive errors. EDDM is particularly useful for detecting gradual drifts earlier than abrupt changes.
Details
EDDM is a statistical process control method that is more sensitive to changes that happen more slowly and can provide early warnings of deterioration before the error rate increases significantly.
Public fields
eddm_warningWarning threshold setting.
eddm_outcontrolOut-of-control threshold setting.
m_num_errorsCurrent number of errors encountered.
m_min_num_errorsMinimum number of errors to initialize drift detection.
m_nTotal instances processed.
m_dDistance to the last error from the current instance.
m_lastdDistance to the previous error from the last error.
m_meanMean of the distances between errors.
m_std_tempTemporary standard deviation accumulator for the distances.
m_m2s_maxMaximum mean plus two standard deviations observed.
delayDelay count since the last detected change.
estimationCurrent estimated mean distance between errors.
warning_detectedBoolean indicating if a warning has been detected.
change_detectedBoolean indicating if a change has been detected.
Methods
Public methods
Method new()
Initializes the EDDM detector with specific parameters.
Usage
EDDM$new(min_num_instances = 30, eddm_warning = 0.95, eddm_outcontrol = 0.9)
Arguments
min_num_instancesMinimum number of errors before drift detection starts.
eddm_warningThreshold for warning level.
eddm_outcontrolThreshold for out-of-control level.
Method reset()
Resets the internal state of the EDDM detector.
Usage
EDDM$reset()
Method add_element()
Adds a new observation and updates the drift detection status.
Usage
EDDM$add_element(prediction)
Arguments
predictionNumeric value representing a new error (usually 0 or 1).
Method clone()
The objects of this class are cloneable with this method.
Usage
EDDM$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
Early Drift Detection Method. Manuel Baena-Garcia, Jose Del Campo-Avila, Raúl Fidalgo, Albert Bifet, Ricard Gavalda, Rafael Morales-Bueno. In Fourth International Workshop on Knowledge Discovery from Data Streams, 2006.
Implementation: https://github.com/scikit-multiflow/scikit-multiflow/blob/a7e316d1cc79988a6df40da35312e00f6c4eabb2/src/skmultiflow/drift_detection/eddm.py
Examples
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)
eddm <- EDDM$new()
for (i in 1:length(data_stream)) {
eddm$add_element(data_stream[i])
if (eddm$change_detected) {
message(paste("Drift detected!",i))
} else if (eddm$warning_detected) {
message(paste("Warning detected!",i))
}
}