Example #1
0
    def process_nca(self, **option):
        '''Metric Learning algorithm: NCA'''
        GeneExp = self.GeneExp_train
        Label = self.Label_train

        nca = NCA(**option)
        nca.fit(GeneExp, Label)
        self.Trans['NCA'] = nca.transformer()
Example #2
0
  def test_iris(self):
    n = self.iris_points.shape[0]
    nca = NCA(max_iter=(100000//n), learning_rate=0.01)
    nca.fit(self.iris_points, self.iris_labels)

    # Result copied from Iris example at
    # https://github.com/vomjom/nca/blob/master/README.mkd
    expected = [[-0.09935, -0.2215,  0.3383,  0.443],
                [+0.2532,   0.5835, -0.8461, -0.8915],
                [-0.729,   -0.6386,  1.767,   1.832],
                [-0.9405,  -0.8461,  2.281,   2.794]]
    assert_array_almost_equal(expected, nca.transformer(), decimal=3)
    def test_iris(self):
        n = self.iris_points.shape[0]
        nca = NCA(max_iter=(100000 // n), learning_rate=0.01)
        nca.fit(self.iris_points, self.iris_labels)

        # Result copied from Iris example at
        # https://github.com/vomjom/nca/blob/master/README.mkd
        expected = [[-0.09935, -0.2215, 0.3383, 0.443],
                    [+0.2532, 0.5835, -0.8461, -0.8915],
                    [-0.729, -0.6386, 1.767, 1.832],
                    [-0.9405, -0.8461, 2.281, 2.794]]
        assert_array_almost_equal(expected, nca.transformer(), decimal=3)
 def test_nca(self):
   n = self.X.shape[0]
   nca = NCA(max_iter=(100000//n), learning_rate=0.01)
   nca.fit(self.X, self.y)
   L = nca.transformer()
   assert_array_almost_equal(L.T.dot(L), nca.metric())
 def test_nca(self):
   n = self.X.shape[0]
   nca = NCA(max_iter=(100000//n), learning_rate=0.01)
   nca.fit(self.X, self.y)
   L = nca.transformer()
   assert_array_almost_equal(L.T.dot(L), nca.metric())