4
$\begingroup$

Suppose I perform dimension reduction using PCA:

dr = DimensionReduction[{{1, 2, 3}, {2, 3, 5}, {3, 5, 8}, {4, 5, 
    8.5}}, Method -> "PrincipalComponentsAnalysis"]

If I want to see the principal components themselves, in the original space, one thought is to use the "OriginalData" feature of the DimensionReducerFunction, on basis vectors in the new space:

In[8]:= dr[{1.0, 0.0}, "OriginalData"]
dr[{0.0, 1.0}, "OriginalData"]

Out[8]= {1.86006, 2.9998, 4.81724}

Out[9]= {3.38701, 3.01026, 5.64163}

Is this a reasonable thing to do, or am I misinterpreting how the "OriginalData" feature works? And is there a better way to pull out the principal components themselves? People often want to visualize these for various reasons.

(There are several other questions about how to solve a similar problem with the PrincipalComponents function; this is a question about a different function.)

$\endgroup$
6
$\begingroup$

Here's your data:

data = {{1, 2, 3}, {2, 3, 5}, {3, 5, 8}, {4, 5, 8.5}};
dr = DimensionReduction[data, Method -> "PrincipalComponentsAnalysis"];

This is not exactly a top level solution, but we can pick apart the DimensionReducerFunction and see inside (try dr[[1]] to see many internal properties).

Looking further, in there we have a matrix:

Transpose[dr[[1, "Model", "Matrix"]]]
{{-0.572383, -0.577502, -0.582125}, {0.793367, -0.56945, -0.215163}}

I think these are the components. We can try to verify:

Transpose[Last[SingularValueDecomposition[Standardize[data], 2]]]
{{-0.572383, -0.577502, -0.582125}, {0.793367, -0.56945, -0.215163}}
$\endgroup$
  • 2
    $\begingroup$ It doesn't look like you need the pre-multiplication by 2/Sqrt[3]; after all, any such rescaling would show itself in the singular values and not the orthogonal factors. The important thing is the shift, which Standardize[] of course does. $\endgroup$ – J. M. will be back soon Mar 31 at 22:12
  • $\begingroup$ Good catch, I've edited the post. I can't remember what I ran into that led me to such a conclusion. $\endgroup$ – Chip Hurst Mar 31 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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