.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_example/plot_example_RBF.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_example_plot_example_RBF.py: Use of Radial Basis Function ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 7-16 .. code-block:: default from smt.sampling_methods import LHS from smt.problems import Sphere from smt.surrogate_models import RBF import numpy as np import otsmt import openturns as ot .. GENERATED FROM PYTHON SOURCE LINES 17-18 | Definition of Initial data .. GENERATED FROM PYTHON SOURCE LINES 18-32 .. code-block:: default # Construction of the DOE fun = Sphere(ndim=2) sampling = LHS(xlimits=fun.xlimits, criterion="m") xt = sampling(40) yt = fun(xt) # Compute the gradient for i in range(2): yd = fun(xt, kx=i) yt = np.concatenate((yt, yd), axis=1) xv = ot.Sample([[0.1,1.],[1.,2.]]) .. GENERATED FROM PYTHON SOURCE LINES 33-34 | Training of smt model for Radial Basis Function .. GENERATED FROM PYTHON SOURCE LINES 34-39 .. code-block:: default sm_rbf = RBF() sm_rbf.set_training_values(xt, yt[:,0]) sm_rbf.train() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ___________________________________________________________________________ RBF ___________________________________________________________________________ Problem size # training points. : 40 ___________________________________________________________________________ Training Training ... Initializing linear solver ... Performing LU fact. (40 x 40 mtx) ... Performing LU fact. (40 x 40 mtx) - done. Time (sec): 0.0001147 Initializing linear solver - done. Time (sec): 0.0001836 Solving linear system (col. 0) ... Back solving (40 x 40 mtx) ... Back solving (40 x 40 mtx) - done. Time (sec): 0.0000541 Solving linear system (col. 0) - done. Time (sec): 0.0001123 Training - done. Time (sec): 0.0006683 .. GENERATED FROM PYTHON SOURCE LINES 40-41 | Creation of OpenTurns PythonFunction for prediction .. GENERATED FROM PYTHON SOURCE LINES 41-44 .. code-block:: default otrbf = otsmt.smt2ot(sm_rbf) otrbfprediction = otrbf.getPredictionFunction() print('Predicted values by RBF:',otrbfprediction(xv)) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ___________________________________________________________________________ Evaluation # eval points. : 2 Predicting ... Predicting - done. Time (sec): 0.0000222 Prediction time/pt. (sec) : 0.0000111 Predicted values by RBF: [ y0 ] 0 : [ 0.00737942 ] 1 : [ 0.022817 ] .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.004 seconds) .. _sphx_glr_download_auto_example_plot_example_RBF.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_example_RBF.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_example_RBF.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_