我想尝试使用描述PCA
做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)
是否可以对具有不同维数的数组进行如下操作?
X = np.array([[-1, -1], [-2, -1], [-3, -2, 3], [1, 1], [2, 1], [3, 2, 3]])
如果我尝试以下错误:
pca = PCA(n_components=2)
pca.fit(X)
ValueError: setting an array element with a sequence.
不,鉴于主成分分析的数学背景,这是不可能的。 PCA是高维空间中的旋转。