Can I run PCA on a 4-tensor? I have a dataset that is a 4D Tensor stored in a numpy array. I would like to do PCA on it, but sklearn.PCA only takes arrays with dim <= 2. I know I can reshape the array, but will that not lose information or cause PCA to fit to the wrong vectors?
 A: There are actually a few generalizations of PCA to higher-order tensors:


*

*The Tucker decomposition used in "higher-order singular value decomposition".

*PARAFAC aka CANDECOMP, is in some ways a special case of Tucker decompositions.

*Another, more recent variant uses the tensor train decomposition.

A: PCA won't work on a 4D tensor, but you could use an auto-encoder.
Note that PCA will take a 2D dataset and reduce the number of columns in it (say 100 columns to 10).
With a 4D dataset, you could use an autoencoder to either reduce it to a 4D dataset with fewer "columns" or reduce it to a 3D dataset.
A: The answer to the question in the title is yes, you can perform a PCA on any set of data described by a coordinate system with any number of axes. The result is a new set of axes, called principal coordinates. The PCA produces as many PC as there are original axes, but the new coordinate system as different properties, such as:


*

*The principal components are ranked based on how much variability
they account for, the first PC being the axis with maximum
variability along itself;

*by definition, all principal components are orthogonal to each other.


Here is a very good interactive explanation of what PCA does and how does it work. For further reference see here, here.
The details in the text body seem to refer to a specific program (I'm guessing Python), which make me think that this question may be more suitable for Stack Overflow.
