m=PCA(n_components=ndim, whiten=True)
m.fit(np.vstack(x))
r=[]for i in x:
r.append(m.transform(i))
return r
////MAIN FUNCTION////
def reduce(arr,ndims=3, method="PCA"):
After Change
def reducePCA(x, ndim):
if np.isnan(np.vstack(x)).any():
warnings.warn("Missing data: Inexact solution computed with PPCA (see https://github.com/allentran/pca-magic for details)")
x_split= np.cumsum([i.shape[0] for i in x][:-1])
m = PPCA(np.vstack(x))
m.fit(d=ndim)
x_pca = m.transform()
return list(np.split(x_pca,x_split,axis=0))
else:
m=PCA(n_components=ndim, whiten=True)
m.fit(np.vstack(x))
return [m.transform(i) for i in x]
////MAIN FUNCTION////
def reduce(arr,ndims=3, method="PCA"):