コード例 #1
0
ファイル: pca_test.py プロジェクト: JesseLivezey/pca
 def change_test(self):
     # Check to see if functions touch original data
     # They should not
     data_init = np.copy(self.data)
     p = PCA(eps=0.)
     p.fit(self.data)
     assert np.allclose(self.data,data_init)
     p.fit_transform(self.data)
     assert np.allclose(self.data,data_init)
     p.inv_transform(self.data)
     assert np.allclose(self.data,data_init)
コード例 #2
0
ファイル: pca_test.py プロジェクト: JesseLivezey/pca
 def dimreduce_test(self):
     # Check to see if intrinsically 2D data
     # can be transformed to 2D and back exactly
     p = PCA(dim=2, eps=0.)
     new = p.fit_transform(self.data)
     new = p.inv_transform(new)
     assert np.allclose(new,self.data)
コード例 #3
0
ファイル: pca_test.py プロジェクト: JesseLivezey/pca
 def transform_test(self):
     # Check to see if data can 
     # be transformed and inverse transformed exactly
     p = PCA(eps=0.)
     new = p.fit_transform(self.data)
     new = p.inv_transform(new)
     assert np.allclose(new,self.data)
コード例 #4
0
ファイル: pca_test.py プロジェクト: JesseLivezey/pca
 def whiten_test(self):
     data = self.data+self.rng.rand(*self.data.shape)
     p = PCA(whiten=True, eps=0.)
     new = p.fit_transform(data)
     cov = new.T.dot(new)
     assert np.allclose(cov,np.eye(data.shape[1]))