()
| 12 | |
| 13 | |
| 14 | def test_nystroem_kernel_approx(): |
| 15 | # test nystroem kernel approx in easy regime (nb anchors = nb points) |
| 16 | n = 30 |
| 17 | d = 3 |
| 18 | Xs = np.random.randn(n, d) |
| 19 | Xt = np.random.randn(n, d) + 2 |
| 20 | sigma = 2.0 |
| 21 | K = np.exp(-ot.dist(Xs, Xt) / (2 * sigma**2)) |
| 22 | U, V = ot.lowrank.kernel_nystroem(Xs, Xt, anchors=60, sigma=sigma, random_state=42) |
| 23 | |
| 24 | np.testing.assert_allclose(K, U @ V.T, atol=1e-7) |
| 25 | |
| 26 | |
| 27 | @pytest.mark.parametrize("log, warn", [[False, False], [True, True]]) |