.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_meta_modeling/kriging_metamodel/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_meta_modeling_kriging_metamodel_plot_kriging_multioutput_firesatellite.py: Example of multi output Kriging on the fire satellite model =========================================================== .. GENERATED FROM PYTHON SOURCE LINES 6-7 This example aims to illustrate Kriging metamodel with several outputs on the fire satellite model. .. GENERATED FROM PYTHON SOURCE LINES 10-14 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 16-24 .. code-block:: default import openturns as ot from openturns.usecases.fireSatellite_function import FireSatelliteModel from openturns.viewer import View ot.Log.Show(ot.Log.NONE) m = FireSatelliteModel() .. GENERATED FROM PYTHON SOURCE LINES 25-26 We define the function that evaluates the outputs depending on the inputs. .. GENERATED FROM PYTHON SOURCE LINES 28-30 .. code-block:: default model = m.model .. GENERATED FROM PYTHON SOURCE LINES 31-32 We also define the distribution of input variables to build the training and test sets. .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: default inputDistribution = m.distributionX .. GENERATED FROM PYTHON SOURCE LINES 38-41 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 43-50 .. code-block:: default 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.55043e+07,858.384,1348.18,12.1472,0.941856,-2.36658,2.56668,1.00003,0.13223] [2.03652e+07,1124.9,1450.72,18.4199,3.23979,2.93037,7.7944,2.93353,1.98141] .. GENERATED FROM PYTHON SOURCE LINES 51-54 Creation of metamodel --------------------- We choose to use a constant trend. .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: default basis = ot.ConstantBasisFactory(m.dim).build() .. GENERATED FROM PYTHON SOURCE LINES 59-60 We would like to have separate covariance models for the three outputs. To do so, we use the `TensorizedCovarianceModel`. For the purpose of illustration, we consider `MaternModel` for the first and third outputs, and `SquaredExponential` for the second output. .. GENERATED FROM PYTHON SOURCE LINES 62-68 .. code-block:: default 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 69-70 The scaling of the data is really important when dealing with Kriging, especially considering the domain definition of the input variables (the altitude varies in order of 1e7 whereas the drag coefficient is around 1). We thus define appropriate bounds for the training algorithm based on the domain definition of each variable. .. GENERATED FROM PYTHON SOURCE LINES 72-77 .. code-block:: default scaleOptimizationBounds = ot.Interval( [1.0, 1.0, 0.1, 0.01, 0.1, 0.1, 0.01, 0.01, 0.001, 0.01, 0.01, 0.01], [1.0e7, 2.0e3, 2.0e3, 1e2, 10.0, 10.0, 10.0, 10.0, 10.0, 1e8, 1e4, 1e3], ) .. GENERATED FROM PYTHON SOURCE LINES 78-79 We can now define the scaled version of Kriging model. .. GENERATED FROM PYTHON SOURCE LINES 79-83 .. code-block:: default covarianceModel.setScale(inputTrainingSet.getMax()) algo = ot.KrigingAlgorithm(inputTrainingSet, outputTrainingSet, covarianceModel, basis) algo.setOptimizationBounds(scaleOptimizationBounds) .. GENERATED FROM PYTHON SOURCE LINES 84-85 We run the algorithm and get the metamodel. .. GENERATED FROM PYTHON SOURCE LINES 85-89 .. code-block:: default algo.run() result = algo.getResult() krigingMetamodel = result.getMetaModel() .. GENERATED FROM PYTHON SOURCE LINES 90-93 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 95-100 .. code-block:: default experimentTest = ot.LHSExperiment(inputDistribution, 50 * m.dim) inputTestSet = experimentTest.generate() outputTestSet = model(inputTestSet) outputKriging = krigingMetamodel(inputTestSet) .. GENERATED FROM PYTHON SOURCE LINES 101-102 Then, we use the `MetaModelValidation` class to validate the metamodel. .. GENERATED FROM PYTHON SOURCE LINES 102-117 .. code-block:: default val = ot.MetaModelValidation(inputTestSet, outputTestSet, krigingMetamodel) Q2 = val.computePredictivityFactor() label = ["Total torque", "Total power", "Solar array area"] for i in range(3): graph = val.drawValidation().getGraph(0, i) graph.setLegends([""]) graph.setLegends(["Q2 = %.2f%%" % (100 * Q2[i]), ""]) graph.setLegendPosition("topleft") graph.setXTitle("Exact function") graph.setYTitle("Metamodel prediction") graph.setTitle(label[i]) View(graph) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_kriging_multioutput_firesatellite_001.png :alt: Total torque :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_kriging_multioutput_firesatellite_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_kriging_multioutput_firesatellite_002.png :alt: Total power :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_kriging_multioutput_firesatellite_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_kriging_multioutput_firesatellite_003.png :alt: Solar array area :srcset: /auto_meta_modeling/kriging_metamodel/images/sphx_glr_plot_kriging_multioutput_firesatellite_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 3.791 seconds) .. _sphx_glr_download_auto_meta_modeling_kriging_metamodel_plot_kriging_multioutput_firesatellite.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. 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-jupyter :download:`Download Jupyter notebook: plot_kriging_multioutput_firesatellite.ipynb `