def test_wrong_dimensions2(self): X1 = np.linspace(-1, 1, 10) X2 = np.linspace(-1, 1, 10) with self.assertRaises(ValueError): pvml.kernel(X1, X2, "polynomial", 2)
def test_polynomial_kernel(self): X = np.linspace(-1, 1, 10).reshape(5, 2) K = pvml.kernel(X, X, "polynomial", 2) evals = np.linalg.eigvalsh(K) self.assertGreaterEqual(evals.min(), 0)
def test_unknown_kernel(self): X = np.linspace(-1, 1, 10).reshape(5, 2) with self.assertRaises(ValueError): pvml.kernel(X, X, "unknown", 2)
def test_rbf_kernel(self): X = np.linspace(-1, 1, 10).reshape(5, 2) K = pvml.kernel(X, X, "rbf", 1) self.assertListEqual(np.diag(K).tolist(), [1] * 5) evals = np.linalg.eigvalsh(K) self.assertGreaterEqual(evals.min(), 0)