Ejemplo n.º 1
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)
Ejemplo n.º 2
0
        def test_custom_sg(self):
            lk = sgK.LinearSGKernel()
            cl = sgK.CustomSGKernel(sgK.sgk.LinearKernel)
            poly = sgK.PolySGKernel()
            poly_params = [('order', 2), ('inhomogenous', True)]
            if not exists('sg ge 0.6.5'):
                poly_params += [('use_normalization', False)]

            custom = sgK.CustomSGKernel(sgK.sgk.PolyKernel,
                                        kernel_params=poly_params)

            d = np.random.randn(253, 52)
            lk.compute(d)
            cl.compute(d)
            poly.compute(d)
            custom.compute(d)

            self.assertTrue(np.all(lk.as_np()._k == cl.as_np()._k),
                            'CustomSGKernel does not agree with Linear')
            self.assertTrue(np.all(poly.as_np()._k == custom.as_np()._k),
                            'CustomSGKernel does not agree with Poly')