Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As far as I can see PrincipalComponents[data] just gives data in the principal component basis. The problem is that after this, I would like to transform new data into the same basis, which requires that I know the actual principal components.

There is the option of calculating Eigenvectors[Covariance[data]] (given the data is centered on the origin) but for the eigenvectors I get this way the signs are usually different from the ones that the PrincipalComponents[] function uses.

Is there an easy way of getting the actual transformation used or transforming new data into the PC basis of the previous dataset?

share|improve this question
up vote 7 down vote accepted

You can do it with FindGeometricTransform[]:

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}};
{error, f} = FindGeometricTransform[PrincipalComponents[data], data];
Norm[PrincipalComponents[data][[1]] - f[data[[1]]]]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.