Note
Click here to download the full example code
Use of Inverse Distance WeightingΒΆ
from smt.sampling_methods import LHS
from smt.problems import Sphere
from smt.surrogate_models import IDW
import numpy as np
import otsmt
import openturns as ot
Definition of Initial data
Training of smt model for Inverse Distance Weighting
sm_idw = IDW(p=2)
sm_idw.set_training_values(xt, yt[:,0])
sm_idw.train()
Out:
___________________________________________________________________________
IDW
___________________________________________________________________________
Problem size
# training points. : 40
___________________________________________________________________________
Training
Training ...
Training - done. Time (sec): 0.0001605
Creation of OpenTurns PythonFunction for prediction
otidw = otsmt.smt2ot(sm_idw)
otidwprediction = otidw.getPredictionFunction()
print('Predicted values by IDW:',otidwprediction(xv))
Out:
___________________________________________________________________________
Evaluation
# eval points. : 2
Predicting ...
Predicting - done. Time (sec): 0.0000257
Prediction time/pt. (sec) : 0.0000129
Predicted values by IDW: [ y0 ]
0 : [ 3.33771 ]
1 : [ 17.8915 ]
Total running time of the script: ( 0 minutes 0.004 seconds)