# Principal Components - how to obtain linear transformations?

I have a list "xlsf" with 6 columns and 1200 rows for PCA analysis. The PrincipalComponents[xlsf] gives the following:

"The principal components of matrix are linear transformations of the original columns into uncorrelated columns arranged in order of decreasing variance"

How do I obtain the transformations performed on columns by Mathematica?

• Use SingularValueDecomposition. Commented Jun 17, 2014 at 16:02
• Or KarhunenLoeveDecomposition Commented Jun 17, 2014 at 18:59

PrincipalComponents is based on SingularValueDecomposition. Below I'll show what it does:

This is some sample data from the docs:

data = {{13.2, 200, 58, 21.2}, {10, 263, 48, 44.5}, {8.1, 294, 80,
31}, {8.8, 190, 50, 19.5}, {9, 276, 91, 40.6}, {7.9, 204, 78,
38.7}, {3.3, 110, 77, 11.1}, {5.9, 238, 72, 15.8}, {15.4, 335,
80, 31.9}, {17.4, 211, 60, 25.8}};


Let's centre it first:

data2 = # - Mean[data] & /@ data;


Then compute the SVD of the centred data:

{u, s, v} = SingularValueDecomposition[data2];


Now Transpose[v] is the rotation that PrincipalComponents applies to each row.

• what happens if I do not center the data? Commented Jun 17, 2014 at 21:49
• @denfromufa Do you understand the mathematics behind PCA? Commented Jun 17, 2014 at 21:55
• now I understand that PCA can be obtained by doing SVD to centralized data: math.stackexchange.com/questions/3869/… Commented Jun 18, 2014 at 22:46
• I'm confused by your last statement. Using your variable names, the PCA-transformed data will then be obtained as data2 . v. Why do you refer to Transpose[v] as the rotation being applied? Commented May 28, 2015 at 7:21
• In Mathematica's Implement, PrincipleCompoments seems a bit from the SVD, use something like eigenSystems for Covariance matrix, because the SVD route gives the same result by DimensionReduce by LSA not the same with PrincipleCompoments Commented Aug 21, 2017 at 3:10