示例#1
0
 def test_linear_kernel(self):
     """Simplistic testing of linear kernel"""
     d1 = Dataset(np.asarray([list(range(5))] * 10, dtype=float))
     lk = npK.LinearKernel()
     lk.compute(d1)
     self.assertTrue(lk._k.shape == (10, 10),
                     "Failure computing LinearKernel (Size mismatch)")
     self.assertTrue((lk._k == 30).all(), "Failure computing LinearKernel")
示例#2
0
        def test_linear_sg(self):
            d1 = np.random.randn(105, 32)
            d2 = np.random.randn(41, 32)

            nk = npK.LinearKernel()
            sk = sgK.LinearSGKernel()
            nk.compute(d1, d2)
            sk.compute(d1, d2)

            self.kernel_equiv(nk, sk)