Using Kriging POD model

After run the Kriging POD model as in this example https://openturns.github.io/otpod/master/examples/krigingPOD.html

How to save the model?
Can I use this model to estimate the output value for new inputs? For example, I want to predict output value for an input like this “[4.5, 4.2, 1.1, 2.6]”

Hello,

Indeed, there is not method that gives you the metamodel coming from the Kriging model.
The KrigingPOD uses the Kriging class of openTURNS and you can get the KrigingResult object. And then from it, it is simple to get the metamodel to predict values for some specific inputs.
However, we have added an initial transformation (only accessible through a private attribute) so the metamodel is not defined into the original space. To do a prediction, you should run this command :

POD.getKrigingResult().getMetaModel()(POD._transformation([4.5, 4.2, 1.1, 2.6]))

Regards,
Antoine

It works.
Thank you so much :slight_smile:

And another problem,
Can I save the trained model? Because It took a lot of time when I trained the model with my own data.

Hello, you can use the “Study” class to save/load all OpenTURNS objects. Here is an example:

https://openturns.github.io/openturns/latest/auto_numerical_methods/general_methods/plot_study_save_load.html

I tried this example before,

I can save the KrigingResults but I could not save the POD,
Because when predicting output for the new input, it also needs the POD to transform input data according to KrigingPOD (POD._transformation())

POD.getKrigingResult().getMetaModel()(POD._transformation([4.5, 4.2, 1.1, 2.6]))

When I tried to save the POD,

study.add('POD', POD)

the error as below:

TypeError Traceback (most recent call last)
Input In [36], in <cell line: 1>()
----> 1 study.add(‘POD’, POD)

File ~\AppData\Roaming\Python\Python39\site-packages\openturns\common.py:660, in Study.add(self, *args)
640 def add(self, *args):
641 r"“”
642 Add an object to the study.
643
(…)
658 otherwise.
659 “”"
→ 660 return _common.Study_add(self, *args)

TypeError: Wrong number or type of arguments for overloaded function ‘Study_add’.
Possible C/C++ prototypes are:
OT::Study::add(OT::InterfaceObject const &)
OT::Study::add(OT::String const &,OT::InterfaceObject const &,OT::Bool)
OT::Study::add(OT::String const &,OT::InterfaceObject const &)
OT::Study::add(OT::PersistentObject const &)
OT::Study::add(OT::String const &,OT::PersistentObject const &,OT::Bool)
OT::Study::add(OT::String const &,OT::PersistentObject const &)

Ah yes, indeed the POD is not an OpenTURNS object and thus cannot be saved via the Study mechanism. However, if what you need in practice is the KrigingResult and the _transformation, you could save them separately, because both are OpenTURNS objects (the _transformation is simply an OpenTURNS Function). Something like this:

study.add('kriging_result', POD.getKrigingResult())
study.add('transformation', POD._transformation)
# ...

### Load study from save file ###
# ...
kriging_result = ot.KrigingResult()
transformation = ot.Function()
study.fillObject('kriging_result', kriging_result)
study.fillObject('transformation', transformation)

It works.
Thank you so much :smiling_face_with_three_hearts: