pca()

Read(2310) Label: matrix, pca, dimensionality reduction,

Description:

External library function (See External Library Guide); perform PCA on a matrix and return data for dimensionality reduction.

Syntax:

pca(A,n)

Perform PCA (Principal Component Analysis) on matrix A and return data for dimensionality reduction; n is the number of principal components

pca(A,F)

Reduce dimensionality for another matrix having same number of columns

Parameter:

A

A matrix

n

Number of principal components

F

The PCA fitting object returned by pca(A,n)

Option:

@r

Enable returning the result of dimensionality reduction on matrix A, which is a matrix of n columns, directly

Return value:

A PCA fitting object or a sequence

Example:

 

A

 

1

[[1,2,3,4],[2,3,1,2],[1,1,1,-1],[1,0,-2,-6]]

 

2

=pca(A1,2)

Return data for dimensionality reduction:

A2(1) Averages of columns;

A2(2) Variances of principal components ordered descendingly.

A2(3) Coefficients of principal components.

3

=pca(A1,A2)

Execute dimensionality reduction on A1.

4

=pca@r(A1,2)

Use @r option to reduce A1’s dimensionality directly; result is the same as A3’s.

5

[[4,6,2,4],[2,3,1,2],[1,1,1,-1]]

 

6

=pca(A5,A2)

Execute dimensionality reduction on another matrix having same number of columns as the original matrix.