Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPX doesn't support vector outputs #679

Open
fzahle opened this issue Nov 20, 2024 · 1 comment
Open

GPX doesn't support vector outputs #679

fzahle opened this issue Nov 20, 2024 · 1 comment

Comments

@fzahle
Copy link
Contributor

fzahle commented Nov 20, 2024

The GPX surrogate doesn't seem to support outputs with ny>1, which works for the other surrogates. It runs, but seems to return the response for the first element only. I guess it could be fixed in here in SMT, but possibly also in the upstream egobox tool. Here's a small test that shows the difference between KRG and GPX:

import unittest
import numpy as np

from smt.surrogate_models import GPX, KRG

from smt.examples.rans_crm_wing.rans_crm_wing import get_rans_crm_wing


class TestNY(unittest.TestCase):
    def test_ny_gpx(self):
        xt, yt, _ = get_rans_crm_wing()

        interp = GPX()
        interp.set_training_values(xt, yt)
        interp.train()
        v0 = np.zeros((4, 2))
        for ix, i in enumerate([10, 11, 12, 13]):
            v0[ix, :] = interp.predict_values(np.atleast_2d(xt[i, :]))
        v1 = interp.predict_values(np.atleast_2d(xt[10:14, :]))

        self.assertEqual(v1.shape[1], yt.shape[1])

    def test_ny_krg(self):
        xt, yt, _ = get_rans_crm_wing()

        interp = KRG()
        interp.set_training_values(xt, yt)
        interp.train()
        v0 = np.zeros((4, 2))
        for ix, i in enumerate([10, 11, 12, 13]):
            v0[ix, :] = interp.predict_values(np.atleast_2d(xt[i, :]))
        v1 = interp.predict_values(np.atleast_2d(xt[10:14, :]))
        self.assertEqual(v1.shape[1], yt.shape[1])
@relf
Copy link
Member

relf commented Nov 20, 2024

Actually, KRG is not meant to handle multiple outputs. It has been recently added (too discreetly!) at the end of the Kriging section but we should definitely raise an error if yt is not one-dimensional. When you use several training outputs you do not get the right predictions (the ones you get if you keep only one training output).
For GPX (or should I say egobox::Gpx), it happens that with the default setting only the first predicted output is kept, but still if you pass several training output data, the prediction you get is not the right one.

I keep this issue open as a reminder till we fix KRG (and kriging-based surrogates) and GPX (ie. raising a ValueError("Multiple outputs not handled") when yt is not one-dimensional).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants