Exemple #1
0
 def test_transform_testing_data(self):
     # check if the num. of neurons in the test data matches the
     # num. of neurons in the training data
     gpfa1 = GPFA(x_dim=self.x_dim, em_max_iters=self.n_iters)
     gpfa1.fit(self.data1)
     with self.assertRaises(ValueError):
         gpfa1.transform(self.data2)
Exemple #2
0
    def test_returned_data(self):
        gpfa = GPFA(bin_size=self.bin_size, x_dim=8, em_max_iters=self.n_iters)
        gpfa.fit(self.data2)
        seqs = gpfa.transform(self.data2)
        self.assertTrue(isinstance(seqs, np.ndarray))

        returned_data = gpfa.valid_data_names
        seqs = gpfa.transform(self.data2, returned_data=returned_data)
        self.assertTrue(len(returned_data) == len(seqs))
        self.assertTrue(isinstance(seqs, dict))
        with self.assertRaises(ValueError):
            seqs = gpfa.transform(self.data2, returned_data=['invalid_name'])
Exemple #3
0
 def test_fit_transform(self):
     gpfa1 = GPFA(bin_size=self.bin_size, x_dim=self.x_dim,
                  em_max_iters=self.n_iters)
     gpfa1.fit(self.data1)
     xorth1 = gpfa1.transform(self.data1)
     xorth2 = GPFA(bin_size=self.bin_size, x_dim=self.x_dim,
                   em_max_iters=self.n_iters).fit_transform(self.data1)
     for i in range(len(self.data1)):
         for j in range(self.x_dim):
             assert_array_almost_equal(xorth1[i][j], xorth2[i][j])
Exemple #4
0
 def test_data2(self):
     gpfa = GPFA(bin_size=self.bin_size, x_dim=8, em_max_iters=self.n_iters)
     gpfa.fit(self.data2)
     n_trials = len(self.data2)
     returned_data = gpfa.valid_data_names
     seqs = gpfa.transform(self.data2, returned_data=returned_data)
     for key, data in seqs.items():
         self.assertEqual(len(data), n_trials,
                          msg="Failed ndarray field {0}".format(key))
     t_start = self.data2[0][0].t_stop
     t_stop = self.data2[0][0].t_start
     n_bins = int(((t_start - t_stop) / self.bin_size).magnitude)
     assert_array_equal(gpfa.transform_info['num_bins'],
                        [n_bins, ] * n_trials)
Exemple #5
0
 def test_data1(self):
     gpfa = GPFA(x_dim=self.x_dim, em_max_iters=self.n_iters)
     gpfa.fit(self.data1)
     xorth = gpfa.transform(self.data1)
     self.assertAlmostEqual(gpfa.transform_info['log_likelihood'],
                            -8172.004695554373, places=5)
     # Since data1 is inherently 2 dimensional, only the first two
     # dimensions of xorth should have finite power.
     for i in [0, 1]:
         self.assertNotEqual(xorth[0][i].mean(), 0)
         self.assertNotEqual(xorth[0][i].var(), 0)
     for i in [2, 3]:
         self.assertAlmostEqual(xorth[0][i].mean(), 0, places=2)
         self.assertAlmostEqual(xorth[0][i].var(), 0, places=2)