Beispiel #1
0
 def test_to_dict_fit_2d(self):
     x = 2 * np.pi * np.random.random_sample((20, 2))
     y = func_2d(x)
     eta = 1e-3
     for kernel in kernels_dict.values():
         k = kernel(2)
         for tail in tails_dict.values():
             t = tail()
             if t.degree >= k.dmin:
                 model = RBF(k, t, eta)
                 model.fit(x, y)
                 output_dict = model.to_dict()
                 assert "X" in output_dict
                 assert "y" in output_dict
                 assert "eta" in output_dict
                 assert "kernel" in output_dict
                 assert "tail" in output_dict
                 assert "lambda" in output_dict
                 assert "LU" in output_dict
                 assert "piv" in output_dict
                 assert "loo" in output_dict
                 assert np.allclose(np.array(output_dict["X"]), model._X)
                 assert np.allclose(np.array(output_dict["y"]), model._y)
                 assert output_dict["eta"] == model._eta
                 assert output_dict["kernel"] == model._kernel.to_dict()
                 assert output_dict["tail"] == model._tail.to_dict()
                 assert np.allclose(np.array(output_dict["lambda"]),
                                    model._lambda)
                 assert np.allclose(np.array(output_dict["LU"]), model._LU)
                 assert np.allclose(np.array(output_dict["piv"]),
                                    model._piv)
                 assert np.allclose(np.array(output_dict["loo"]),
                                    model.loo_residuals)
Beispiel #2
0
 def test_to_dict_nofit(self):
     eta = 1
     for kernel in kernels_dict.values():
         k = kernel(2)
         for tail in tails_dict.values():
             t = tail()
             if t.degree >= k.dmin:
                 model = RBF(k, t, eta)
                 output_dict = model.to_dict()
                 assert "eta" in output_dict
                 assert "kernel" in output_dict
                 assert "tail" in output_dict
                 assert output_dict["eta"] == model._eta
                 assert output_dict["kernel"] == model._kernel.to_dict()
                 assert output_dict["tail"] == model._tail.to_dict()