Note
Click here to download the full example code
Use of Least Squares Surrogate ModelΒΆ
from smt.sampling_methods import LHS
from smt.problems import Sphere
from smt.surrogate_models import LS
import numpy as np
import otsmt
import openturns as ot
Definition of Initial data
Training of smt model for Least Squares
sm_ls = LS()
sm_ls.set_training_values(xt, yt[:,0])
sm_ls.train()
Out:
___________________________________________________________________________
LS
___________________________________________________________________________
Problem size
# training points. : 40
___________________________________________________________________________
Training
Training ...
Training - done. Time (sec): 0.0012939
Creation of OpenTurns PythonFunction for prediction
otls = otsmt.smt2ot(sm_ls)
otlsprediction = otls.getPredictionFunction()
print('Predicted values by LS:',otlsprediction(xv))
Out:
___________________________________________________________________________
Evaluation
# eval points. : 2
Predicting ...
Predicting - done. Time (sec): 0.0001111
Prediction time/pt. (sec) : 0.0000556
Predicted values by LS: [ y0 ]
0 : [ 66.4082 ]
1 : [ 65.3 ]
Total running time of the script: ( 0 minutes 0.005 seconds)