CCIPCA: A function to perform CCIPCA

Description Usage Arguments Details Value Author(s) References Examples

View source: R/CCIPCA.R

Description

Candid Covariance-Free Incremental PCA (CCIPCA) without estimation of covariance matrix

Usage

1
CCIPCA(data = NA, runmode = "OnMemory", filelist = NA, dim, param)

Arguments

data

data matrix.

runmode

"OnMemory" or "FileLoading" is available.

filelist

Local path for specifying data file, when runmode is "FileLoading".

dim

Dimention to be compressed (No. of principal component)

param

Amnesia parameter. 2 to 4 is recommended.

Details

Unlike with the standard PCA (principal component analysis) functions such as prcomp, eigen, or svd, this function loads the data from each row of the data matrix and estimates eigen vectors and eigen values with incremental calculation. Standard PCA algorithms become very slow, when the variables we want to analyze at once is huge (e.g., 10^4 to 10^6), caused by expanded covariance matrix. CCIPCA estimates the eigen vectors and eigen values directlly from data, without calculation of covariance matrix.

Value

A list with fields

values

Eigen values

vectors

Eigen vectors

Author(s)

Koki Tsuyuzaki

References

Weng J. et al. (2003). Candid covariance-free incremental principal component analysis. IEEE Transactions on Pattern Analysis and Machine Intelligence

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Standart PCA
data <- t(USArrests)
pca1 <- svd(var(data))
pca2 <- eigen(var(data))
pca3 <- prcomp(data)

# Onmemory mode
pca4 <- CCIPCA(data=data, dim=3, param=2)

# FileLoading mode
## Not run: 
opendir <- function(dir = getwd()){
  if(.Platform['OS.type'] == "windows"){
    shell.exec(dir)
  }else{
    system(paste(Sys.getenv("R_BROWSER"), dir))
  }
}
## End(Not run)
## Not run: opendir(tempdir())
## Not run: filelist <- paste0(tempdir(), "/", rownames(data))
## Not run: 
for(i in 1:nrow(data)){
  write.table(data[i,], file=filelist[i], sep=",", row.names=F, col.names=F)
}
## End(Not run)
## Not run: pca5 <- CCIPCA(runmode="FileLoading", filelist=filelist, dim=3, param=2)
## Not run: library("rgl")
## Not run: plot3d(pca1$u[,1], pca1$u[,2], pca1$u[,3])
## Not run: plot3d(pca2$vectors[,1], pca2$vectors[,2], pca2$vectors[,3])
## Not run: plot3d(pca3$rotation[,1], pca3$rotation[,2], pca3$rotation[,3])
## Not run: plot3d(pca4$vectors[,1], pca4$vectors[,2], pca4$vectors[,3])
## Not run: plot3d(pca5$vectors[,1], pca5$vectors[,2], pca5$vectors[,3])

rikenbit/CCIPCA documentation built on May 27, 2019, 9:09 a.m.