def test_predict_consistent_structured(): # Check binary predict decision has also predicted probability above 0.5. X = ["A", "AB", "B"] y = np.array([True, False, True]) kernel = MiniSeqKernel(baseline_similarity_bounds="fixed") gpc = GaussianProcessClassifier(kernel=kernel).fit(X, y) assert_array_equal(gpc.predict(X), gpc.predict_proba(X)[:, 1] >= 0.5)
def test_gpr_interpolation_structured(): # Test the interpolating property for different kernels. kernel = MiniSeqKernel(baseline_similarity_bounds="fixed") X = ["A", "B", "C"] y = np.array([1, 2, 3]) gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) y_pred, y_cov = gpr.predict(X, return_cov=True) assert_almost_equal( kernel(X, eval_gradient=True)[1].ravel(), (1 - np.eye(len(X))).ravel()) assert_almost_equal(y_pred, y) assert_almost_equal(np.diag(y_cov), 0.0)