(N=15)
| 85 | |
| 86 | |
| 87 | def test_gp_regression(N=15): |
| 88 | np.random.seed(12345) |
| 89 | |
| 90 | i = 0 |
| 91 | while i < N: |
| 92 | alpha = np.random.rand() |
| 93 | N = np.random.randint(2, 100) |
| 94 | M = np.random.randint(2, 100) |
| 95 | K = np.random.randint(1, N) |
| 96 | J = np.random.randint(1, 3) |
| 97 | |
| 98 | X = np.random.rand(N, M) |
| 99 | y = np.random.rand(N, J) |
| 100 | X_test = np.random.rand(K, M) |
| 101 | |
| 102 | gp = GPRegression(kernel="RBFKernel(sigma=1)", alpha=alpha) |
| 103 | gold = GaussianProcessRegressor( |
| 104 | kernel=None, alpha=alpha, optimizer=None, normalize_y=False |
| 105 | ) |
| 106 | |
| 107 | gp.fit(X, y) |
| 108 | gold.fit(X, y) |
| 109 | |
| 110 | preds, _ = gp.predict(X_test) |
| 111 | gold_preds = gold.predict(X_test) |
| 112 | np.testing.assert_almost_equal(preds, gold_preds) |
| 113 | |
| 114 | mll = gp.marginal_log_likelihood() |
| 115 | gold_mll = gold.log_marginal_likelihood() |
| 116 | np.testing.assert_almost_equal(mll, gold_mll) |
| 117 | |
| 118 | print("PASSED") |
| 119 | i += 1 |
nothing calls this directly
no test coverage detected