1430ab58648b4bd189f232ae2acc8b86ce2fd9aa,python/hypertools/reduce.py,,reducePCA,#Any#Any#,18

Before Change


	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


from sklearn.decomposition import PCA as PCA

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"):
    if method=="PCA":
        return reducePCA(arr,ndims)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 7

Instances


Project Name: ContextLab/hypertools
Commit Name: 1430ab58648b4bd189f232ae2acc8b86ce2fd9aa
Time: 2016-12-17
Author: andrew.heusser@gmail.com
File Name: python/hypertools/reduce.py
Class Name:
Method Name: reducePCA


Project Name: scipy/scipy
Commit Name: b0f34cdfd3ec8e41521cfd1b4a19c8dabb51fbbf
Time: 2020-02-15
Author: pvanmulbregt@users.noreply.github.com
File Name: scipy/stats/_ksstats.py
Class Name:
Method Name: _kolmogn


Project Name: ContextLab/hypertools
Commit Name: ab4c3743ec1c77d67ddede9fb400b55b3778e39b
Time: 2016-12-17
Author: andrew.heusser@gmail.com
File Name: python/hypertools/reduce.py
Class Name:
Method Name: reducePCA


Project Name: scipy/scipy
Commit Name: b0f34cdfd3ec8e41521cfd1b4a19c8dabb51fbbf
Time: 2020-02-15
Author: pvanmulbregt@users.noreply.github.com
File Name: scipy/stats/_ksstats.py
Class Name:
Method Name: _kolmogn_p