emax
emax

Reputation: 7245

Python: is it possible to do PCA with a vector with multiple dimensions?

I would like to try to do PCA using the description here

from sklearn.decomposition import PCA
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
pca = PCA(n_components=2)
pca.fit(X)
PCA(n_components=2)

Is it possible to do the same with an array with different dimensions such as the following?

X = np.array([[-1, -1], [-2, -1], [-3, -2, 3], [1, 1], [2, 1], [3, 2, 3]])

if I try I get the following error:

pca = PCA(n_components=2)
pca.fit(X)
ValueError: setting an array element with a sequence.

Upvotes: 1

Views: 1153

Answers (1)

ypnos
ypnos

Reputation: 52327

No, this is not possible given the mathematical background of Principal Component Analysis. PCA is a rotation in the high-dimensional space.

Upvotes: 1

Related Questions