Skip to contents

For forgetting = 1, the processor retains Chan-Golub-LeVeque sufficient statistics and is batch-equivalent without retaining samples. Smaller forgetting factors produce an explicitly exponentially weighted covariance.

Usage

incrementalPCA(n_components, n_features = NULL, forgetting = 1, center = TRUE)

Arguments

n_components

Number of retained components.

n_features

Optional feature count to bind at construction.

forgetting

Per-sample covariance forgetting factor in (0, 1].

center

Whether to estimate and subtract a running mean.

Value

A mutable IncrementalPCA streaming processor.

Examples

set.seed(1)
latent <- matrix(rnorm(300), ncol = 3)
samples <- latent %*% matrix(rnorm(12), 3, 4)
pca <- incrementalPCA(n_components = 2L)
result <- update(pca, samples)
result$diagnostics$explained_variance
#> [1] 8.033294 4.948562