Exemple #1
0
 def test_infer_dim_3(self):
     n, p = 100, 5
     rng = np.random.RandomState(0)
     X = mt.tensor(rng.randn(n, p) * .1)
     X[:10] += mt.array([3, 4, 5, 1, 2])
     X[10:20] += mt.array([6, 0, 7, 2, -1])
     X[30:40] += 2 * mt.array([-1, 1, -1, 1, -1])
     pca = PCA(n_components=p, svd_solver='full')
     pca.fit(X)
     spect = pca.explained_variance_.fetch()
     self.assertGreater(_infer_dimension(spect, n), 2)
Exemple #2
0
 def test_infer_dim_2(self):
     # TODO: explain what this is testing
     # Or at least use explicit variable names...
     n, p = 1000, 5
     rng = np.random.RandomState(0)
     X = mt.tensor(rng.randn(n, p) * .1)
     X[:10] += mt.array([3, 4, 5, 1, 2])
     X[10:20] += mt.array([6, 0, 7, 2, -1])
     pca = PCA(n_components=p, svd_solver='full')
     pca.fit(X)
     spect = pca.explained_variance_.fetch()
     self.assertGreater(_infer_dimension(spect, n), 1)