Main Content

reset

Reset incremental principal component analysis model

Since R2024a

    Description

    IncrementalMdl = reset(IncrementalMdl) returns the incrementalPCA model IncrementalMdl with reset principal component analysis (PCA) properties. If any hyperparameters of IncrementalMdl are estimated during incremental fitting, the reset function resets them as well. reset preserves the NumPredictors, NumComponents, EstimationPeriod, WarmupPeriod, and VariableWeights properties of IncrementalMdl. However, the reset function resets WarmupPeriod to the default value of 1000 if you specify Coefficients and Latent (but do not specify WarmupPeriod) when you create IncrementalMdl.

    example

    Examples

    collapse all

    Create an incremental PCA model, fit the model, and then reset it after fitting to compare the model properties.

    Load Data

    Load the ionospheric data in ionosphere.mat.

    load ionosphere.mat

    Create Incremental PCA Model Object

    Create a model for incremental PCA. Specify a warm-up period of 100 observations, and standardize the predictor data using an estimation period of 100 observations. Specify the first variable weight as 1 and the remaining variable weights as 0.5.

    IncrementalMdl = incrementalPCA(StandardizeData=true, ...
        WarmupPeriod=100,EstimationPeriod=100, ...
        VariableWeights=[1;0.5*ones(size(X,2)-1,1)]);

    Display the properties of the IncrementalMdl model object.

    details(IncrementalMdl)
      incrementalPCA with properties:
    
                         IsWarm: 0
        NumTrainingObservations: 0
                   WarmupPeriod: 100
                             Mu: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
                          Sigma: [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
              ExplainedVariance: [34x1 double]
               EstimationPeriod: 100
                         Latent: [34x1 double]
                   Coefficients: [34x34 double]
                VariableWeights: [1 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 ... ] (1x34 double)
                  NumComponents: 34
                  NumPredictors: 34
    

    IncrementalMdl is an incrementalPCA model object. The model is not warm, meaning that the fit function does not return transformed data until it processes 200 observations.

    Fit Incremental Model

    Fit the incremental model IncrementalMdl to the data by using the fit function. To simulate a data stream, fit the model in chunks of 10 observations at a time. At each iteration:

    • Process 10 observations.

    • Overwrite the previous incremental model with a new one fitted to the incoming observations.

    n = numel(X(:,1));
    numObsPerChunk = 10;
    nchunk = floor(n/numObsPerChunk);
    
    % Incremental fitting
    for j = 1:nchunk
        ibegin = min(n,numObsPerChunk*(j-1) + 1);
        iend = min(n,numObsPerChunk*j);
        IncrementalMdl = fit(IncrementalMdl,X(ibegin:iend,:));
    end

    Display the properties of the fitted IncrementalMdl model object.

    details(IncrementalMdl)
      incrementalPCA with properties:
    
                         IsWarm: 1
        NumTrainingObservations: 250
                   WarmupPeriod: 100
                             Mu: [0.8300 0 0.6670 -0.0380 0.6708 0.0688 0.6655 -0.0140 0.6300 0.0748 0.5715 0.0963 0.5414 0.1195 0.4708 -0.0354 0.5263 0.0075 0.4527 -0.0185 0.4390 0.0798 0.3596 -0.0106 0.4956 -0.0706 0.6263 -0.0296 0.2949 ... ] (1x34 double)
                          Sigma: [0.3756 0 0.5669 0.5297 0.5386 0.5222 0.5144 0.5640 0.5202 0.5310 0.6145 0.5843 0.5476 0.5236 0.6301 0.5532 0.6114 0.6216 0.6637 0.6501 0.6264 0.6105 0.6634 0.6409 0.6032 0.6497 0.4746 0.6716 0.6981 0.6541 ... ] (1x34 double)
              ExplainedVariance: [34x1 double]
               EstimationPeriod: 100
                         Latent: [34x1 double]
                   Coefficients: [34x34 double]
                VariableWeights: [1 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 ... ] (1x34 double)
                  NumComponents: 34
                  NumPredictors: 34
    

    Reset Incremental Model

    Reset the fitted incremental model and compare it to the previous model to see which properties are reset.

    newMdl = reset(IncrementalMdl);
    details(newMdl)
      incrementalPCA with properties:
    
                         IsWarm: 0
        NumTrainingObservations: 0
                   WarmupPeriod: 100
                             Mu: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
                          Sigma: [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
              ExplainedVariance: [34x1 double]
               EstimationPeriod: 100
                         Latent: [34x1 double]
                   Coefficients: [34x34 double]
                VariableWeights: [1 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 ... ] (1x34 double)
                  NumComponents: 34
                  NumPredictors: 34
    
    sum(newMdl.Coefficients(:))
    ans = 
    0
    
    sum(newMdl.Latent)
    ans = 
    0
    
    sum(newMdl.ExplainedVariance)
    ans = 
    0
    

    The reset function resets all model properties except the warm-up period, estimation period, variable weights, number of components, and number of predictors.

    Input Arguments

    collapse all

    Incremental PCA model, specified as an incrementalPCA model object. You can create IncrementalMdl by calling incrementalPCA directly.

    Version History

    Introduced in R2024a

    See Also

    Functions