.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_getting_started/plot_kriging_vs_gpr.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_getting_started_plot_kriging_vs_gpr.py: Gaussian Process Regression vs KrigingAlgorithm ================================================ .. GENERATED FROM PYTHON SOURCE LINES 7-12 The goal of this example is to highlight the main changes between the old API involving `KrigingAlgorithm` and the new one. It assumes a basic knowledge of Gaussian Process Regression. For that purpose, we create a Gaussian Process Regression surrogate model for a function which has scalar real inputs and outputs. We select a very simple example. .. GENERATED FROM PYTHON SOURCE LINES 14-34 Introduction ------------ We consider the sine function: .. math:: y = x \sin(x) for any :math:`x\in[0,12]`. We want to create a surrogate of this function. This is why we create a sample of :math:`n` observations of the function: .. math:: y_i=x_i \sin(x_i) We are going to consider a Gaussian Process Regression with: * a constant trend, * a Matern covariance model. .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: Python import openturns as ot import openturns.viewer as otv .. GENERATED FROM PYTHON SOURCE LINES 41-43 First let us introduce some useful function. In order to observe the function and the location of the points in the input design of experiments, we define `plot_1d_data`. .. GENERATED FROM PYTHON SOURCE LINES 46-86 .. code-block:: Python def plot_1d_data(x_data, y_data, type="Curve", legend=None, color=None, linestyle=None): """Plot the data (x_data,y_data) as a Cloud/Curve""" if type == "Curve": graphF = ot.Curve(x_data, y_data) else: graphF = ot.Cloud(x_data, y_data) if legend is not None: graphF.setLegend(legend) if color is not None: graphF.setColor(color) if linestyle is not None: graphF.setLineStyle(linestyle) return graphF def computeQuantileAlpha(alpha): """ Compute bilateral confidence interval of level 1-alpha of a gaussian distribution. """ bilateralCI = ot.Normal().computeBilateralConfidenceInterval(1 - alpha) return bilateralCI.getUpperBound()[0] def computeBoundsConfidenceInterval(y_test_hat, quantileAlpha, conditionalSigma): """ Compute the 1-alpha confidence interval bounds. """ dataLower = [ [y_test_hat[i, 0] - quantileAlpha * conditionalSigma[i, 0]] for i in range(n_test) ] dataUpper = [ [y_test_hat[i, 0] + quantileAlpha * conditionalSigma[i, 0]] for i in range(n_test) ] dataLower = ot.Sample(dataLower) dataUpper = ot.Sample(dataUpper) return dataLower, dataUpper .. GENERATED FROM PYTHON SOURCE LINES 87-89 .. code-block:: Python g = ot.SymbolicFunction(["x"], ["x * sin(x)"]) .. GENERATED FROM PYTHON SOURCE LINES 90-98 .. code-block:: Python xmin = 0.0 xmax = 12.0 n_train = 20 step = (xmax - 1 - xmin) / (n_train - 1.0) x_train = ot.RegularGrid(xmin + 0.2, step, n_train).getVertices() y_train = g(x_train) n_train = x_train.getSize() .. GENERATED FROM PYTHON SOURCE LINES 99-101 In order to compare the function and its metamodel, we use a test (i.e. validation) design of experiments made of a regular grid of 100 points from 0 to 12. Then we convert this grid into a :class:`~openturns.Sample` and we compute the outputs of the function on this sample. .. GENERATED FROM PYTHON SOURCE LINES 103-109 .. code-block:: Python n_test = 100 step = (xmax - xmin) / (n_test - 1) myRegularGrid = ot.RegularGrid(xmin, step, n_test) x_test = myRegularGrid.getVertices() y_test = g(x_test) .. GENERATED FROM PYTHON SOURCE LINES 110-111 We plot the true function (continuous dashed curve) and train data (cloud points) on the same figure. .. GENERATED FROM PYTHON SOURCE LINES 111-124 .. code-block:: Python graph = ot.Graph("Function of interest", "", "") graph.add( plot_1d_data(x_test, y_test, legend="Exact", color="black", linestyle="dashed") ) graph.add( plot_1d_data(x_train, y_train, type="Cloud", legend="Train points", color="red") ) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") view = otv.View(graph) .. image-sg:: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_001.svg :alt: Function of interest :srcset: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 125-127 We use the :class:`~openturns.ConstantBasisFactory` class to define the trend and the :class:`~openturns.MaternModel` class to define the covariance model. This Matérn model is based on the regularity parameter :math:`\nu=3/2`. .. GENERATED FROM PYTHON SOURCE LINES 129-133 .. code-block:: Python dimension = 1 basis = ot.ConstantBasisFactory(dimension).build() covarianceModel = ot.MaternModel([1.0] * dimension, 1.5) .. GENERATED FROM PYTHON SOURCE LINES 134-135 In the following, we use the `KrigingAlgorithm` class to fit the Gaussian Process Regression model (aka Kriging). .. GENERATED FROM PYTHON SOURCE LINES 137-142 .. code-block:: Python kriging_algo = ot.KrigingAlgorithm(x_train, y_train, covarianceModel, basis) kriging_algo.run() kriging_result = kriging_algo.getResult() krigingMM = kriging_result.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 143-147 We observe that the `scale` and `amplitude` hyper-parameters have been optimized by the `run` method. The default optimization method (used here) is the :class:`~openturns.TNC` With the new API, the :class:`~openturns.GaussianProcessFitter` class is used to fit the gaussian process and :class:`~openturns.GaussianProcessRegression` to get the conditioned model. .. GENERATED FROM PYTHON SOURCE LINES 149-157 .. code-block:: Python fitter_algo = ot.GaussianProcessFitter(x_train, y_train, covarianceModel, basis) fitter_algo.run() fitter_result = fitter_algo.getResult() gpr_algo = ot.GaussianProcessRegression(fitter_result) gpr_algo.run() gpr_result = gpr_algo.getResult() gprMetamodel = gpr_result.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 158-161 We observe that the `scale` and `amplitude` hyper-parameters have been optimized by the :meth:`~openturns.GaussianProcessFitter.run` method. The default optimization method (used here) is the :class:`~openturns.Cobyla`, which is different from the old API. Then we get the metamodel with `getMetaModel` for evaluating the outputs of the metamodel on the test design of experiments. .. GENERATED FROM PYTHON SOURCE LINES 163-164 Now we plot Gaussian process Regression output, in addition to the previous plots .. GENERATED FROM PYTHON SOURCE LINES 166-185 .. code-block:: Python graph = ot.Graph("Comparison data vs GP models", "", "") graph.add(plot_1d_data(x_test, y_test, legend="Exact", color="black")) graph.add(plot_1d_data(x_train, y_train, type="Cloud", legend="Data", color="red")) graph.add( plot_1d_data( x_test, krigingMM(x_test), legend="Kriging", color="blue", linestyle="dashed" ) ) graph.add( plot_1d_data( x_test, gprMetamodel(x_test), legend="GPR", color="green", linestyle="dotdash" ) ) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") view = otv.View(graph) .. image-sg:: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_002.svg :alt: Comparison data vs GP models :srcset: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_002.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 186-193 We see that the Gaussian process regression estimated with both classes is interpolating. This is what is meant by *conditioning* a Gaussian process. We see that, when the sine function has a strong curvature between two points which are separated by a large distance (e.g. between :math:`x=4` and :math:`x=6`), then the Gaussian regression is not close to the function :math:`g`. However, when the training points are close (e.g. between :math:`x=11` and :math:`x=11.5`) or when the function is nearly linear (e.g. between :math:`x=8` and :math:`x=11`), then the gaussian process regression is quite accurate. .. GENERATED FROM PYTHON SOURCE LINES 195-200 Activating nugget factor ------------------------ Both APIs allow one to estimate the model with an active nugget factor thanks to the :meth:`~openturns.CovarianceModel.activateNuggetFactor`, e.g. the parameter is estimated within the optimization process. .. GENERATED FROM PYTHON SOURCE LINES 202-206 .. code-block:: Python covarianceModel.activateNuggetFactor(True) ot.RandomGenerator.SetSeed(1235) epsilon = ot.Normal(0, 1.5).getSample(y_train.getSize()) .. GENERATED FROM PYTHON SOURCE LINES 207-218 .. code-block:: Python kriging_algo_wnf = ot.KrigingAlgorithm( x_train, y_train + epsilon, covarianceModel, basis ) kriging_algo_wnf.setOptimizationAlgorithm(ot.NLopt("GN_DIRECT")) kriging_algo_wnf.run() kriging_result_wnf = kriging_algo_wnf.getResult() krigingMM_wnf = kriging_result_wnf.getMetaModel() print( f"Nugget factor estimated with Kriging class = {kriging_result_wnf.getCovarianceModel().getNuggetFactor()}" ) .. rst-class:: sphx-glr-script-out .. code-block:: none Nugget factor estimated with Kriging class = 0.038103947568970974 .. GENERATED FROM PYTHON SOURCE LINES 219-233 .. code-block:: Python fitter_algo_wnf = ot.GaussianProcessFitter( x_train, y_train + epsilon, covarianceModel, basis ) fitter_algo_wnf.setOptimizationAlgorithm(ot.NLopt("GN_DIRECT")) fitter_algo_wnf.run() fitter_result_wnf = fitter_algo_wnf.getResult() gpr_algo_wnf = ot.GaussianProcessRegression(fitter_result_wnf) gpr_algo_wnf.run() gpr_result_wnf = gpr_algo_wnf.getResult() gprMetamodel_wnf = gpr_result_wnf.getMetaModel() print( f"Nugget factor estimated with GPR class = {gpr_result_wnf.getCovarianceModel().getNuggetFactor()}" ) .. rst-class:: sphx-glr-script-out .. code-block:: none Nugget factor estimated with GPR class = 0.03810394756997059 .. GENERATED FROM PYTHON SOURCE LINES 234-235 We plot the test and train data .. GENERATED FROM PYTHON SOURCE LINES 235-267 .. code-block:: Python graph = ot.Graph("test and train with noisy data", "", "") graph.add(plot_1d_data(x_test, y_test, legend="Exact", color="black")) graph.add( plot_1d_data( x_train, y_train + epsilon, type="Cloud", legend="Noisy data", color="red" ) ) graph.add( plot_1d_data( x_test, krigingMM_wnf(x_test), legend="Kriging", color="blue", linestyle="dashed", ) ) graph.add( plot_1d_data( x_test, gprMetamodel_wnf(x_test), legend="GPR", color="green", linestyle="dotdash", ) ) graph.setAxes(True) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") view = otv.View(graph) .. image-sg:: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_003.svg :alt: test and train with noisy data :srcset: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_003.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 268-270 Compute confidence bounds ------------------------- .. GENERATED FROM PYTHON SOURCE LINES 272-281 In order to assess the quality of the surrogate model, we can estimate the variance and compute a 95% confidence interval associated with the conditioned Gaussian process. We begin by defining the `alpha` variable containing the complementary of the confidence level than we want to compute. Then we compute the quantile of the Gaussian distribution corresponding to `1-alpha/2`. Therefore, the confidence interval is: .. math:: P\in\left(X\in\left[q_{\alpha/2},q_{1-\alpha/2}\right]\right)=1-\alpha. .. GENERATED FROM PYTHON SOURCE LINES 283-288 .. code-block:: Python alpha = 0.05 quantileAlpha = computeQuantileAlpha(alpha) print("alpha=%f" % (alpha)) print("Quantile alpha=%f" % (quantileAlpha)) .. rst-class:: sphx-glr-script-out .. code-block:: none alpha=0.050000 Quantile alpha=1.959964 .. GENERATED FROM PYTHON SOURCE LINES 289-296 In order to compute the regression error, we can consider the conditional variance. Within the old API, the `KrigingResult.getConditionalMarginalVariance` method returns the marginal variance `marVar` evaluated at each points in the given sample. Then we can apply the sqrt function to get the standard deviation. Notice that some coefficients in the diagonal are very close to zero and nonpositive, which might lead to an exception when applying the sqrt function. This is why we add an epsilon on the diagonal, which prevents this issue. .. GENERATED FROM PYTHON SOURCE LINES 298-305 .. code-block:: Python sqrt = ot.SymbolicFunction(["x"], ["sqrt(x)"]) epsilon = ot.Sample(n_test, [1.0e-8]) conditional_variance_kriging = ( kriging_result.getConditionalMarginalVariance(x_test) + epsilon ) conditional_sigma_kriging = sqrt(conditional_variance_kriging) .. GENERATED FROM PYTHON SOURCE LINES 306-313 Within the new API, the :meth:`~openturns.GaussianProcessConditionalCovariance.getConditionalMarginalVariance` applies and returns the marginal variance `marVar` Since this is a variance, we use the square root in order to compute the standard deviation. Notice also that :meth:`~openturns.GaussianProcessConditionalCovariance.getConditionalCovariance` is similar to `KrigingResult.getConditionalCovariance`, and :meth:`~openturns.GaussianProcessConditionalCovariance.getDiagonalCovarianceCollection` has a "twin" method `KrigingResult.getConditionalMarginalCovariance`., .. GENERATED FROM PYTHON SOURCE LINES 315-319 .. code-block:: Python gccc = ot.GaussianProcessConditionalCovariance(gpr_result) conditional_variance_gpr = gccc.getConditionalMarginalVariance(x_test) conditional_sigma_gpr = sqrt(conditional_variance_gpr) .. GENERATED FROM PYTHON SOURCE LINES 320-321 Let us compute the same conditional standard deviation when accounting for the noise. .. GENERATED FROM PYTHON SOURCE LINES 323-332 .. code-block:: Python conditional_variance_kriging_wnf = ( kriging_result_wnf.getConditionalMarginalVariance(x_test) + epsilon ) conditional_sigma_kriging_wnf = sqrt(conditional_variance_kriging_wnf) gccc_wnf = ot.GaussianProcessConditionalCovariance(gpr_result_wnf) conditional_variance_gpr_wnf = gccc_wnf.getConditionalMarginalVariance(x_test) + epsilon conditional_sigma_gpr_wnf = sqrt(conditional_variance_gpr_wnf) .. GENERATED FROM PYTHON SOURCE LINES 333-334 The following figure presents the conditional standard deviation depending on :math:`x`. .. GENERATED FROM PYTHON SOURCE LINES 336-348 .. code-block:: Python graph = ot.Graph( "Conditional standard deviation", "x", "Conditional standard deviation" ) curve = ot.Curve(x_test, conditional_sigma_kriging) graph.add(curve) curve = ot.Curve(x_test, conditional_sigma_gpr) graph.add(curve) graph.setColors(["blue", "red"]) graph.setLegends(["kriging", "GPR"]) graph.setLegendPosition("upper right") view = otv.View(graph) .. image-sg:: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_004.svg :alt: Conditional standard deviation :srcset: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_004.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 349-350 Select the green colors using HSV values (for the confidence interval) .. GENERATED FROM PYTHON SOURCE LINES 350-352 .. code-block:: Python mycolors = [120, 1.0, 1.0] .. GENERATED FROM PYTHON SOURCE LINES 353-355 We are ready to display all the previous information and the three confidence intervals we want. First let us evaluate the different confidence bounds .. GENERATED FROM PYTHON SOURCE LINES 357-370 .. code-block:: Python ci_lower_bound_km, ci_upper_bound_km = computeBoundsConfidenceInterval( krigingMM(x_test), quantileAlpha, conditional_sigma_kriging ) ci_lower_bound_km_noise, ci_upper_bound_km_noise = computeBoundsConfidenceInterval( krigingMM_wnf(x_test), quantileAlpha, conditional_sigma_kriging_wnf ) ci_lower_bound_gpr, ci_upper_bound_gpr = computeBoundsConfidenceInterval( gprMetamodel(x_test), quantileAlpha, conditional_sigma_gpr ) ci_lower_bound_gpr_noise, ci_upper_bound_gpr_noise = computeBoundsConfidenceInterval( gprMetamodel_wnf(x_test), quantileAlpha, conditional_sigma_gpr_wnf ) .. GENERATED FROM PYTHON SOURCE LINES 371-372 Now we loop over the different models .. GENERATED FROM PYTHON SOURCE LINES 374-393 .. code-block:: Python grid_layout = ot.GridLayout(2, 2) grid_layout.setTitle("Confidence interval with various models") graph = ot.Graph("Kriging API", "x", "y") boundsPoly = ot.Polygon.FillBetween(x_test, ci_lower_bound_km, ci_upper_bound_km) boundsPoly.setColor(ot.Drawable.ConvertFromHSV(mycolors[0], mycolors[1], mycolors[2])) boundsPoly.setLegend(" %d%% bounds" % ((1.0 - alpha) * 100)) graph.add(boundsPoly) graph.add( plot_1d_data(x_test, y_test, legend="Exact", color="black", linestyle="dashed") ) graph.add(plot_1d_data(x_train, y_train, type="Cloud", legend="Data", color="red")) graph.add(plot_1d_data(x_test, krigingMM(x_test), legend="Kriging", color="blue")) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") grid_layout.setGraph(0, 0, graph) .. GENERATED FROM PYTHON SOURCE LINES 394-395 Gaussian Process Regression .. GENERATED FROM PYTHON SOURCE LINES 397-414 .. code-block:: Python graph = ot.Graph("GPR API", "x", "y") boundsPoly = ot.Polygon.FillBetween(x_test, ci_lower_bound_gpr, ci_upper_bound_gpr) boundsPoly.setColor(ot.Drawable.ConvertFromHSV(mycolors[0], mycolors[1], mycolors[2])) boundsPoly.setLegend(" %d%% bounds" % ((1.0 - alpha) * 100)) graph.add(boundsPoly) graph.add( plot_1d_data(x_test, y_test, legend="Exact", color="black", linestyle="dashed") ) graph.add(plot_1d_data(x_train, y_train, type="Cloud", legend="Data", color="red")) graph.add(plot_1d_data(x_test, gprMetamodel(x_test), legend="GPR", color="blue")) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") grid_layout.setGraph(0, 1, graph) .. GENERATED FROM PYTHON SOURCE LINES 415-416 Kriging with noise (old API) .. GENERATED FROM PYTHON SOURCE LINES 418-443 .. code-block:: Python graph = ot.Graph("Kriging API", "x", "y") boundsPoly = ot.Polygon.FillBetween( x_test, ci_lower_bound_km_noise, ci_upper_bound_km_noise ) boundsPoly.setColor(ot.Drawable.ConvertFromHSV(mycolors[0], mycolors[1], mycolors[2])) boundsPoly.setLegend(" %d%% bounds" % ((1.0 - alpha) * 100)) graph.add(boundsPoly) graph.add(plot_1d_data(x_test, y_test, legend="Exact", color="black")) graph.add(plot_1d_data(x_train, y_train, type="Cloud", legend="Data", color="red")) graph.add( plot_1d_data( x_test, krigingMM_wnf(x_test), legend="Kriging + noise", color="blue", linestyle="dashed", ) ) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") grid_layout.setGraph(1, 0, graph) .. GENERATED FROM PYTHON SOURCE LINES 444-445 Gaussian Process Regression with noise .. GENERATED FROM PYTHON SOURCE LINES 447-470 .. code-block:: Python graph = ot.Graph("GPR API", "x", "y") boundsPoly = ot.Polygon.FillBetween( x_test, ci_lower_bound_gpr_noise, ci_upper_bound_gpr_noise ) boundsPoly.setColor(ot.Drawable.ConvertFromHSV(mycolors[0], mycolors[1], mycolors[2])) boundsPoly.setLegend(" %d%% bounds" % ((1.0 - alpha) * 100)) graph.add(boundsPoly) graph.add( plot_1d_data(x_test, y_test, legend="Exact", color="black", linestyle="dashed") ) graph.add(plot_1d_data(x_train, y_train, type="Cloud", legend="Data", color="red")) graph.add( plot_1d_data(x_test, gprMetamodel_wnf(x_test), legend="GPR + noise", color="blue") ) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") grid_layout.setGraph(1, 1, graph) view = otv.View(grid_layout) .. image-sg:: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_005.svg :alt: Confidence interval with various models, Kriging API, GPR API, Kriging API, GPR API :srcset: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_005.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 471-474 We see that the confidence intervals are small in the regions where two consecutive training points are close to each other. With noisy data, the confidence interval become bigger. .. GENERATED FROM PYTHON SOURCE LINES 476-478 Gaussian Process Regression with fixed trend -------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 480-483 The new Gaussian Process Regression allows one to estimate a conditioned Gaussian process regression if covariance models are fixed and with a given trend function. Here after how it applies for our use-case. First we set the known parameters (covariance, trend) .. GENERATED FROM PYTHON SOURCE LINES 485-490 .. code-block:: Python scale = [4.51669] amplitude = [8.648] covariance_opt = ot.MaternModel(scale, amplitude, 1.5) trend_function = ot.SymbolicFunction("x", "-3.1710410094572903") .. GENERATED FROM PYTHON SOURCE LINES 491-492 Then we define the Gaussian Process Regression relying on these parameters: .. GENERATED FROM PYTHON SOURCE LINES 494-501 .. code-block:: Python gpr_algo_noopt = ot.GaussianProcessRegression( x_train, y_train, covariance_opt, trend_function ) gpr_algo_noopt.run() gpr_result_no_opt = gpr_algo_noopt.getResult() gpr_nopt_Metamodel = gpr_result_no_opt.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 502-503 Plot the function .. GENERATED FROM PYTHON SOURCE LINES 505-517 .. code-block:: Python graph = ot.Graph("GPR with known trend", "", "") graph.add( plot_1d_data(x_test, y_test, legend="Exact", color="black", linestyle="dashed") ) graph.add(plot_1d_data(x_train, y_train, type="Cloud", legend="Data", color="red")) graph.add(plot_1d_data(x_test, gpr_nopt_Metamodel(x_test), legend="GPR", color="green")) graph.setAxes(True) graph.setXTitle("X") graph.setYTitle("Y") graph.setLegendPosition("upper right") view = otv.View(graph) .. image-sg:: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_006.svg :alt: GPR with known trend :srcset: /auto_getting_started/images/sphx_glr_plot_kriging_vs_gpr_006.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 518-519 The given GPR matches with the data as expected ! .. GENERATED FROM PYTHON SOURCE LINES 521-524 ------------------- Summary of features ------------------- .. GENERATED FROM PYTHON SOURCE LINES 526-534 We illustrated some the features of both old/new API, making a comparison in terms of usage and result. We can summarize the main differences hereafter (old API / new API): * Default optimization solver : :class:`~openturns.TNC`/:class:`~openturns.Cobyla` * Conditional covariance : `KrigingResult.getConditionalCovariance`/ :meth:`~openturns.GaussianProcessConditionalCovariance.getConditionalCovariance` * Known trend : no / yes (see : :class:`~openturns.GaussianProcessRegression` ) * Nugget factor : yes / yes * Fit the model : `KrigingAlgorithm.run` / :meth:`~openturns.GaussianProcessFitter.run` + :meth:`~openturns.GaussianProcessRegression.run` .. GENERATED FROM PYTHON SOURCE LINES 536-537 Display all figures .. GENERATED FROM PYTHON SOURCE LINES 537-538 .. code-block:: Python otv.View.ShowAll() .. _sphx_glr_download_auto_getting_started_plot_kriging_vs_gpr.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_kriging_vs_gpr.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_kriging_vs_gpr.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_kriging_vs_gpr.zip `