Main Content

reset

Reset incremental regression model

Since R2022a

    Description

    Mdl = reset(Mdl) returns the incremental model Mdl with reset learned parameters. If any hyperparameters of Mdl are estimated during incremental training, reset function resets these hyperparameters as well. reset always preserves Mdl.Numpredictors.

    example

    Examples

    collapse all

    Load the robot arm data set. Obtain the sample size n and the number of predictor variables p.

    load robotarm
    n = numel(ytrain);
    p = size(Xtrain,2);

    For details on the data set, enter Description at the command line.

    Create an incremental linear model for regression. Configure the model as follows:

    • Specify a metrics warm-up period of 1000 observations.

    • Specify a metrics window size of 500 observations.

    • Configure the model to predict responses by specifying that all regression coefficients and the bias are 0.

    Mdl = incrementalRegressionLinear('MetricsWarmupPeriod',1000,'MetricsWindowSize',500, ...
        'Beta',zeros(p,1),'Bias',0,'EstimationPeriod',0)
    Mdl = 
      incrementalRegressionLinear
    
                   IsWarm: 0
                  Metrics: [1x2 table]
        ResponseTransform: 'none'
                     Beta: [32x1 double]
                     Bias: 0
                  Learner: 'svm'
    
    
    

    Mdl is an incrementalRegressionLinear model object configured for incremental learning. All properties are read-only.

    Simulate a data stream with incoming chunks of 50 observations each. For each iteration:

    1. Call updateMetricsAndFit to update the performance metrics and fit the model to the incoming window of data. Overwrite the previous incremental model with the new one.

    2. Investigate the model.

    3. Call reset to reset the learned parameters and compare to the previous model to see which parameters are reset.

    numObsPerChunk = 50;
    nchunk = floor(n/numObsPerChunk);
    for j = 1:nchunk
        ibegin = min(n,numObsPerChunk*(j-1) + 1);
        iend   = min(n,numObsPerChunk*j);
        idx = ibegin:iend;    
        Mdl = updateMetricsAndFit(Mdl,Xtrain(idx,:),ytrain(idx));
        L(j) = loss(Mdl,Xtrain(idx,:),ytrain(idx));
        PoL(j,:) = perObservationLoss(Mdl,Xtrain(idx,:),ytrain(idx));
    end

    Display the model.

    Mdl
    Mdl = 
      incrementalRegressionLinear
    
                   IsWarm: 1
                  Metrics: [1x2 table]
        ResponseTransform: 'none'
                     Beta: [32x1 double]
                     Bias: -1.9425e-04
                  Learner: 'svm'
    
    
    

    The model is warm (IsWarm=1), you can see the values of some of the properties.

    Display the Metrics property.

    Mdl.Metrics
    ans=1×2 table
                                  Cumulative    Window 
                                  __________    _______
    
        EpsilonInsensitiveLoss     0.68922      0.68538
    
    

    This property contains the model performance metrics, which, in this case, is the epsilon insensitive loss. It shows the cumulative loss and the loss for the latest data window.

    Display the model coefficients.

    Mdl.Beta(1:10)
    ans = 10×1
    
       -0.0002
       -0.0002
       -0.0004
        0.0000
        0.0006
        0.0000
        0.0003
       -0.0010
        0.0004
       -0.0011
    
    

    Reset the model and display the same parameters.

    newMdl = reset(Mdl)
    newMdl = 
      incrementalRegressionLinear
    
                   IsWarm: 0
                  Metrics: [1x2 table]
        ResponseTransform: 'none'
                     Beta: [32x1 double]
                     Bias: 0
                  Learner: 'svm'
    
    
    
    newMdl.Metrics
    ans=1×2 table
                                  Cumulative    Window
                                  __________    ______
    
        EpsilonInsensitiveLoss       NaN         NaN  
    
    
    newMdl.Beta(1:10)
    ans = 10×1
    
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
    
    

    reset function resets the warmup status of the model (IsWarm = 0), the values of the performance metrics, and the estimated model parameters. In addition to these, it resets the properties, such as NumTrainingObservations, that the software updates at each iteration.

    Input Arguments

    collapse all

    Incremental learning model, specified as an incrementalRegressionKernel or incrementalRegressionLinear model object. You can create Mdl directly or by converting a supported, traditionally trained machine learning model using the incrementalLearner function. For more details, see the corresponding object page.

    Version History

    Introduced in R2022a