Note
Click here to download the full example code
Use of Second-order polynomial approximationΒΆ
from smt.sampling_methods import LHS
from smt.problems import Sphere
from smt.surrogate_models import QP
import numpy as np
import otsmt
import openturns as ot
Definition of Initial data
Training of smt model for Second-order polynomial approximation
sm_qp = QP()
sm_qp.set_training_values(xt, yt[:,0])
sm_qp.train()
Out:
___________________________________________________________________________
                                    QP
___________________________________________________________________________
 Problem size
      # training points.        : 40
___________________________________________________________________________
 Training
   Training ...
   Training - done. Time (sec):  0.0003443
Creation of OpenTurns PythonFunction for prediction
otqp =  otsmt.smt2ot(sm_qp)
otqpprediction = otqp.getPredictionFunction()
print('Predicted values by QP:',otqpprediction(xv))
Out:
___________________________________________________________________________
 Evaluation
      # eval points. : 2
   Predicting ...
   Predicting - done. Time (sec):  0.0000496
   Prediction time/pt. (sec) :  0.0000248
Predicted values by QP:     [ y0   ]
0 : [ 1.01 ]
1 : [ 5    ]
Total running time of the script: ( 0 minutes 0.323 seconds)
 otsmt
      otsmt