.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_surrogate_modeling/gaussian_process_regression/plot_kriging_multioutput_firesatellite.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_surrogate_modeling_gaussian_process_regression_plot_kriging_multioutput_firesatellite.py: Multi-output Gaussian Process Regression on the fire satellite model ==================================================================== .. GENERATED FROM PYTHON SOURCE LINES 7-8 This example aims to illustrate Gaussian Process Fitter (Kriging) metamodel with several outputs on the fire satellite model. .. GENERATED FROM PYTHON SOURCE LINES 11-15 Loading of the model -------------------- This model involves 9 input variables and 3 output variables. We load the :ref:`Fire satellite use case`. .. GENERATED FROM PYTHON SOURCE LINES 17-22 .. code-block:: Python import openturns as ot from openturns.usecases.fire_satellite import FireSatelliteModel import openturns.experimental as otexp import openturns.viewer as otv .. GENERATED FROM PYTHON SOURCE LINES 23-24 We define the function that evaluates the outputs depending on the inputs. .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: Python m = FireSatelliteModel() model = m.model .. GENERATED FROM PYTHON SOURCE LINES 28-29 We also define the distribution of input variables to build the training and test sets. .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: Python inputDistribution = m.distribution .. GENERATED FROM PYTHON SOURCE LINES 33-36 Generation of data ------------------ We now generate the input and output training sets as 10 times the dimension of the input vector. .. GENERATED FROM PYTHON SOURCE LINES 38-45 .. code-block:: Python experiment = ot.LHSExperiment(inputDistribution, 10 * m.dim) inputTrainingSet = experiment.generate() outputTrainingSet = model(inputTrainingSet) print("Lower and upper bounds of inputTrainingSet:") print(inputTrainingSet.getMin(), inputTrainingSet.getMax()) .. rst-class:: sphx-glr-script-out .. code-block:: none Lower and upper bounds of inputTrainingSet: [1.51682e+07,887.129,1348.53,12.4228,1.00107,0.269929,2.60879,0.972964,0.274082] [2.04071e+07,1122.44,1445.97,17.4763,3.19127,0.750975,7.3782,3.01005,1.69896] .. GENERATED FROM PYTHON SOURCE LINES 46-49 Creation of metamodel --------------------- We choose to use a constant trend. .. GENERATED FROM PYTHON SOURCE LINES 51-59 .. code-block:: Python linear_basis = ot.LinearBasisFactory(m.dim).build() basis = ot.Basis( [ ot.AggregatedFunction([linear_basis.build(k)] * 3) for k in range(linear_basis.getSize()) ] ) .. GENERATED FROM PYTHON SOURCE LINES 60-63 We would like to have separate covariance models for the three outputs. To do so, we use the :class:`~openturns.TensorizedCovarianceModel`. For the purpose of illustration, we consider :class:`~openturns.MaternModel` for the first and third outputs, and :class:`~openturns.SquaredExponential` for the second output. .. GENERATED FROM PYTHON SOURCE LINES 65-70 .. code-block:: Python myCov1 = ot.MaternModel([1.0] * m.dim, 2.5) myCov2 = ot.SquaredExponential([1.0] * m.dim) myCov3 = ot.MaternModel([1.0] * m.dim, 2.5) covarianceModel = ot.TensorizedCovarianceModel([myCov1, myCov2, myCov3]) .. GENERATED FROM PYTHON SOURCE LINES 71-72 We can now define the GP fitter model. .. GENERATED FROM PYTHON SOURCE LINES 72-77 .. code-block:: Python fitter_algo = otexp.GaussianProcessFitter( inputTrainingSet, outputTrainingSet, covarianceModel, basis ) fitter_algo.setOptimizeParameters(True) .. GENERATED FROM PYTHON SOURCE LINES 78-79 We run the algorithm and get the metamodel. .. GENERATED FROM PYTHON SOURCE LINES 79-86 .. code-block:: Python fitter_algo.run() fitter_result = fitter_algo.getResult() gpr_algo = otexp.GaussianProcessRegression(fitter_result) gpr_algo.run() gpr_result = gpr_algo.getResult() gprMetamodel = gpr_result.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 87-90 Validation of metamodel ----------------------- To validate the metamodel, we create a validation set of size equal to 50 times the input vector dimension to evaluate the functions. .. GENERATED FROM PYTHON SOURCE LINES 90-95 .. code-block:: Python ot.RandomGenerator.SetSeed(1) experimentTest = ot.LHSExperiment(inputDistribution, 50 * m.dim) inputTestSet = experimentTest.generate() outputTestSet = model(inputTestSet) .. GENERATED FROM PYTHON SOURCE LINES 96-97 Then, we use the :class:`~openturns.MetaModelValidation` class to validate the metamodel. .. GENERATED FROM PYTHON SOURCE LINES 97-102 .. code-block:: Python metamodelPredictions = gprMetamodel(inputTestSet) val = ot.MetaModelValidation(outputTestSet, metamodelPredictions) r2Score = val.computeR2Score() print("R2=", r2Score) .. rst-class:: sphx-glr-script-out .. code-block:: none R2= [0.988917,0.992692,0.984453] .. GENERATED FROM PYTHON SOURCE LINES 103-104 Graphical validation .. GENERATED FROM PYTHON SOURCE LINES 104-115 .. code-block:: Python label = ["Total torque", "Total power", "Solar array area"] for i in range(3): graph = val.drawValidation().getGraph(0, i) graph.setLegends([""]) graph.setLegends(["R2 = %.2f%%" % (100 * r2Score[i]), ""]) graph.setLegendPosition("upper left") graph.setXTitle("Exact function") graph.setYTitle("Metamodel prediction") graph.setTitle(label[i]) otv.View(graph) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_surrogate_modeling/gaussian_process_regression/images/sphx_glr_plot_kriging_multioutput_firesatellite_001.svg :alt: Total torque :srcset: /auto_surrogate_modeling/gaussian_process_regression/images/sphx_glr_plot_kriging_multioutput_firesatellite_001.svg :class: sphx-glr-multi-img * .. image-sg:: /auto_surrogate_modeling/gaussian_process_regression/images/sphx_glr_plot_kriging_multioutput_firesatellite_002.svg :alt: Total power :srcset: /auto_surrogate_modeling/gaussian_process_regression/images/sphx_glr_plot_kriging_multioutput_firesatellite_002.svg :class: sphx-glr-multi-img * .. image-sg:: /auto_surrogate_modeling/gaussian_process_regression/images/sphx_glr_plot_kriging_multioutput_firesatellite_003.svg :alt: Solar array area :srcset: /auto_surrogate_modeling/gaussian_process_regression/images/sphx_glr_plot_kriging_multioutput_firesatellite_003.svg :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 116-117 .. code-block:: Python otv.View.ShowAll() .. _sphx_glr_download_auto_surrogate_modeling_gaussian_process_regression_plot_kriging_multioutput_firesatellite.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_multioutput_firesatellite.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_kriging_multioutput_firesatellite.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_kriging_multioutput_firesatellite.zip `