SMTorg / smt

Surrogate Modeling Toolbox
https://smt.readthedocs.io/en/stable
BSD 3-Clause "New" or "Revised" License
642 stars 196 forks source link

SGP Gradients unsupported #583

Open NAThompson opened 3 weeks ago

NAThompson commented 3 weeks ago

Visualization of the function returned from SGP indicates that this model of the data is indeed differentiable. However, the .gradient method is not defined:

sgp = SGP()
sgp.set_training_values(xs, ys)
sgp.train()
sgp.gradient([1.2, 2.3, 4.6])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~venv/lib/python3.12/site-packages/smt/surrogate_models/surrogate_model.py", line 333, in predict_derivatives
    check_support(self, "derivatives")
  File "~venv/lib/python3.12/site-packages/smt/utils/checks.py", line 25, in check_support
    raise NotImplementedError("{} does not support {}".format(class_name, name))
NotImplementedError: SGP does not support derivatives

Are gradient fundamentally unavailable, or could this be implemented?

relf commented 3 weeks ago

To the best of my knowledge, sparse GP derivatives can be implemented. We just need a PR. 😉