Пример #1
0
    def test_hessian(self):
        """Check the hessian function returns the correct values."""
        clf = RVC()

        x = np.array([[1, 2], [3, 4]])
        y = np.array([[5, 6], [7, 8]])

        phi = clf._apply_kernel(x, y)

        alpha = np.ones(3)
        m = np.ones(3)
        t = np.array([1, 0])

        hessian = clf._hessian(m, alpha, phi, t)

        h_target = np.array([[1, 4.018e-10, 3.571e-03],
                             [4.018e-10, 1, 2.194e-08],
                             [3.571e-03, 2.194e-08, 1.392]])

        np.testing.assert_allclose(hessian, h_target, rtol=1e-3)