Main Content

reset

Reset incremental concept drift detector

Since R2022a

    Description

    IncCDDetector = reset(IncCDDetector) resets internal states of the incremental concept drift detector IncCDDetector, including PreviousDriftStatus and DriftStatus. Call reset after detectdrift concludes on a drift in the data.

    example

    Examples

    collapse all

    Create a random stream such that the first 500 observations come from a normal distribution with mean 2 and standard deviation 0.75 and the next 500 come from a normal distribution with mean 4 and standard deviation 1. In an incremental drift detection application, access to data stream and model update would happen consecutively. However, for the purpose of clarification, this example demonstrates the simulation of data separately.

    rng(1234) % For reproducibility
    numObservations = 1000;
    switchPeriod1 = 500;
    X = zeros([numObservations 1]);
    for i = 1:numObservations
        if i <= switchPeriod1
            X(i) = normrnd(2,0.75);
        else
            X(i) = normrnd(4,1);
        end
    end

    Initiate the incremental concept drift detector. Utilize the Hoeffding's bound method with exponential moving average method (HDDMA). Specify the input type as continuous, a warmup of 50 observations, and an estimation period of 50 observations.

    incCDDetector = incrementalConceptDriftDetector("hddma",InputType="continuous", ...
        WarmupPeriod=50,EstimationPeriod=50)
    incCDDetector = 
      HoeffdingDriftDetectionMethod
    
            PreviousDriftStatus: 'Stable'
                    DriftStatus: 'Stable'
                         IsWarm: 0
        NumTrainingObservations: 0
                    Alternative: 'greater'
                      InputType: 'continuous'
                     TestMethod: 'average'
    
    
    

    incDDetector is a HoeffdingDriftDetectionMethod object. When you first create the object, properties such as DriftStatus, IsWarm, CutMean, and NumTrainingObservations are at their initial state. detectdrift updates them as you feed the data incrementally and monitor for drift.

    Simulate the data stream of one observation at a time and perform incremental drift detection until a drift is detected.

    i=1;
    while incCDDetector.DriftDetected~=1
        incCDDetector = detectdrift(incCDDetector,X(i));
        i=i+1;
        if incCDDetector.DriftDetected
           sprintf("Drift detected at observation #%d.",i)
           incCDDetector
        end      
    end
    ans = 
    "Drift detected at observation #518."
    
    incCDDetector = 
      HoeffdingDriftDetectionMethod
    
            PreviousDriftStatus: 'Warning'
                    DriftStatus: 'Drift'
                         IsWarm: 1
        NumTrainingObservations: 467
                    Alternative: 'greater'
                      InputType: 'continuous'
                     TestMethod: 'average'
    
    
    

    The drift status switched from a Warning to a Drift (drift is detected) at observation 518. detectdrift starts updating the internal statistics after the estimation period, which is 50, hence the number of training observations is 467.

    Reset and investigate the drift detector.

    incCDDetector = reset(incCDDetector)
    incCDDetector = 
      HoeffdingDriftDetectionMethod
    
            PreviousDriftStatus: 'Stable'
                    DriftStatus: 'Stable'
                         IsWarm: 0
        NumTrainingObservations: 0
                    Alternative: 'greater'
                      InputType: 'continuous'
                     TestMethod: 'average'
    
    
    

    reset function resets the internal statistics such as CutMean, PostCutMean, InputBounds, and NumTrainingObservations, the drift statuses PreviousDriftStatus and DriftStatus, and the indicators IsWarm, DriftDetected, and WarningDetected.

    Input Arguments

    collapse all

    Incremental concept drift detector, specified as either DriftDetectionMethod or HoeffdingDriftDetectionMethod object. For more information on these objects and their properties, see the corresponding reference pages.

    Version History

    Introduced in R2022a