示例#1
0
 def test_init_numtoobig(self):
     tf.PCA(num_comp=8).fit(DATA1)
示例#2
0
 def test_init_nan(self):
     tf.PCA().fit(np.array([[1, 2, 3], [1, np.nan, 3]]))
示例#3
0
 def test_init_inf(self):
     tf.PCA().fit(np.array([[1, 2, 3], [1, np.inf, 3]]))
示例#4
0
 def test_init_withnum(self):
     pca = tf.PCA(num_comp=2)
     assert pca.num_comp == 2
示例#5
0
 def test_init_vec(self):
     tf.PCA().fit(np.array([1, 2, 3]))
示例#6
0
 def test_project_shape1(self):
     data_proj = tf.PCA(num_comp=2).fit(DATA1).project(DATA1)
     assert data_proj.shape == DATA1.shape
示例#7
0
 def test_init_nonum(self):
     pca = tf.PCA().fit(DATA1)
     assert pca.num_comp == DATA1.shape[1]
示例#8
0
 def test_transform_shape2(self):
     data_trans = tf.PCA().fit(DATA1).transform(DATA2, num_comp=2)
     assert data_trans.shape == (DATA2.shape[0], 2)
示例#9
0
 def test_transform_diff_shape(self):
     tf.PCA().fit(DATA1).transform(DATA2[:, :2])
示例#10
0
 def test_transform_allcomp_other(self):
     data_trans = tf.PCA().fit(DATA1).transform(DATA2)
     assert data_trans.shape == DATA2.shape
示例#11
0
 def test_transform_allcomp_vec(self):
     vec = np.array([1, 2, 3, 4])
     data_trans = tf.PCA().fit(DATA1).transform(vec)
     assert data_trans.shape == vec.shape
示例#12
0
 def test_project_numtoobig(self):
     tf.PCA().fit(DATA1).project(DATA1, num_comp=8)
示例#13
0
 def test_project_diff_shape(self):
     tf.PCA().fit(DATA1).project(DATA2[:, :2])
示例#14
0
 def test_project_shape2(self):
     data_proj = tf.PCA().fit(DATA1).project(DATA2, num_comp=2)
     assert data_proj.shape == DATA2.shape
示例#15
0
 def test_project_allcomp_self(self):
     assert np.allclose(DATA1, tf.PCA().fit(DATA1).project(DATA1))
示例#16
0
 def test_transform_numtoobig(self):
     tf.PCA().fit(DATA1).transform(DATA1, num_comp=8)
示例#17
0
 def test_project_allcomp_other(self):
     assert np.allclose(DATA2, tf.PCA().fit(DATA1).project(DATA2))
示例#18
0
 def test_project_allcomp_vec(self):
     vec = np.array([1, 2, 3, 4])
     assert np.allclose(vec, tf.PCA().fit(DATA1).project(vec))