Skip to content

Commit

Permalink
CircleCI build openturns 18113
Browse files Browse the repository at this point in the history
  • Loading branch information
CircleCI committed Apr 26, 2024
1 parent 6ab9f87 commit fe87347
Show file tree
Hide file tree
Showing 485 changed files with 4,784 additions and 3,131 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Sobol' sensitivity indices using rank-based algorithm\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import openturns as ot\nimport openturns.experimental as otexp\nimport openturns.viewer as viewer\nfrom openturns.usecases import ishigami_function"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example we are going to compute global sensitivity indices in a data driven framework.\nFor that purpose, we are using the rank-based algorithm which provides the first order Sobol' indices.\nWe present the method on the `Ishigami function<use-case-ishigami>`.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ot.Log.Show(ot.Log.NONE)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Definition of the model\n\nWe load the model from the usecases module.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"im = ishigami_function.IshigamiModel()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We generate an input sample of size 500 (and dimension 3).\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"size = 500\not.RandomGenerator.SetSeed(10)\nX = im.distributionX.getSample(size)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We compute the output by applying the Ishigami model to the input sample.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"Y = im.model(X)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Estimate Sobol' first order indices via rank-based algorithm.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"mySobol = otexp.RankSobolSensitivityAlgorithm(X, Y)\nindices = mySobol.getFirstOrderIndices()\nprint('First order indices:', indices)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Draw Sobol' indices.\n\nOptions for confidence interval estimation can be defined.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ot.ResourceMap.SetAsUnsignedInteger('SobolIndicesAlgorithm-DefaultBootstrapSize', 200)\not.ResourceMap.SetAsScalar('RankSobolSensitivityAlgorithm-DefaultBootstrapSampleRatio', 0.85)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"if SobolIndicesAlgorithm-DefaultBootstrapSize > 1, the draw() method will call bootstrap method to compute the confidence intervals.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"graph = mySobol.draw()\ngraph.setTitle(\"Sobol' indices\")\nview = viewer.View(graph)\n\nprint('confidence intervals:', mySobol.getFirstOrderIndicesInterval())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is possible that Sobol' indices estimates take negative values, that is inconsistent with the theory. Therefore, a larger number of samples is required to get consistent indices.\n\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
},
"outputs": [],
"source": [
"optimAlgo = ot.Cobyla()\noptimAlgo.setMaximumCallsNumber(1000)\noptimAlgo.setMaximumAbsoluteError(1.0e-10)\noptimAlgo.setMaximumRelativeError(1.0e-10)\noptimAlgo.setMaximumResidualError(1.0e-10)\noptimAlgo.setMaximumConstraintError(1.0e-10)"
"optimAlgo = ot.Cobyla()\noptimAlgo.setMaximumCallsNumber(1000)\noptimAlgo.setMaximumAbsoluteError(1.0e-8)\noptimAlgo.setMaximumRelativeError(1.0e-10)\noptimAlgo.setMaximumResidualError(1.0e-10)\noptimAlgo.setMaximumConstraintError(1.0e-10)"
]
},
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# %%
optimAlgo = ot.Cobyla()
optimAlgo.setMaximumCallsNumber(1000)
optimAlgo.setMaximumAbsoluteError(1.0e-10)
optimAlgo.setMaximumAbsoluteError(1.0e-8)
optimAlgo.setMaximumRelativeError(1.0e-10)
optimAlgo.setMaximumResidualError(1.0e-10)
optimAlgo.setMaximumConstraintError(1.0e-10)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# - Spearman coefficients
# - Taylor expansion importance factors
# - Sobol' indices
# - Rank-based estimation of Sobol' indices
# - HSIC : Hilbert-Schmidt Independence Criterion
#
# We present the methods on the :ref:`WingWeight function<use-case-wingweight>` and use the same notations.
Expand All @@ -26,6 +27,7 @@
#
#
import openturns as ot
import openturns.experimental as otexp
import openturns.viewer as otv
from openturns.usecases.wingweight_function import WingWeightModel
from matplotlib import pylab as plt
Expand Down Expand Up @@ -366,6 +368,20 @@
graph.setTitle("Sobol indices by Polynomial Chaos Expansion - wing weight")
view = otv.View(graph)


# %%
# Furthermore, first order Sobol' indices can also been estimated in a data-driven way using a rank-based sensitivity algorithm.
# In such a way, the estimation of sensitivity indices does not involve any surrogate model.
sizeRankSobol = 800
inputDesignRankSobol = m.distributionX.getSample(sizeRankSobol)
outputDesignankSobol = m.model(inputDesignRankSobol)
myRankSobol = otexp.RankSobolSensitivityAlgorithm(inputDesignRankSobol, outputDesignankSobol)
indicesrankSobol = myRankSobol.getFirstOrderIndices()
print('First order indices:', indicesrankSobol)
graph = myRankSobol.draw()
graph.setTitle("Sobol indices by rank-based estimation - wing weight")
view = otv.View(graph)

# %%
#
# The Sobol' indices confirm the previous analyses, in terms of ranking of the most influent variables.
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This example is a brief overview of the use of the most usual sensitivity analysis techniques and how to call them:\n\n- PCC: Partial Correlation Coefficients\n- PRCC: Partial Rank Correlation Coefficients\n- SRC: Standard Regression Coefficients\n- SRRC: Standard Rank Regression Coefficients\n- Pearson coefficients\n- Spearman coefficients\n- Taylor expansion importance factors\n- Sobol' indices\n- HSIC : Hilbert-Schmidt Independence Criterion\n\nWe present the methods on the `WingWeight function<use-case-wingweight>` and use the same notations.\n\n"
"This example is a brief overview of the use of the most usual sensitivity analysis techniques and how to call them:\n\n- PCC: Partial Correlation Coefficients\n- PRCC: Partial Rank Correlation Coefficients\n- SRC: Standard Regression Coefficients\n- SRRC: Standard Rank Regression Coefficients\n- Pearson coefficients\n- Spearman coefficients\n- Taylor expansion importance factors\n- Sobol' indices\n- Rank-based estimation of Sobol' indices\n- HSIC : Hilbert-Schmidt Independence Criterion\n\nWe present the methods on the `WingWeight function<use-case-wingweight>` and use the same notations.\n\n"
]
},
{
Expand All @@ -29,7 +29,7 @@
},
"outputs": [],
"source": [
"import openturns as ot\nimport openturns.viewer as otv\nfrom openturns.usecases.wingweight_function import WingWeightModel\nfrom matplotlib import pylab as plt\nimport numpy as np\n\not.Log.Show(ot.Log.NONE)\nm = WingWeightModel()"
"import openturns as ot\nimport openturns.experimental as otexp\nimport openturns.viewer as otv\nfrom openturns.usecases.wingweight_function import WingWeightModel\nfrom matplotlib import pylab as plt\nimport numpy as np\n\not.Log.Show(ot.Log.NONE)\nm = WingWeightModel()"
]
},
{
Expand Down Expand Up @@ -594,6 +594,24 @@
"firstOrder = [sensitivityAnalysis.getSobolIndex(i) for i in range(m.dim)]\ntotalOrder = [sensitivityAnalysis.getSobolTotalIndex(i) for i in range(m.dim)]\ngraph = ot.SobolIndicesAlgorithm.DrawSobolIndices(inputNames, firstOrder, totalOrder)\ngraph.setTitle(\"Sobol indices by Polynomial Chaos Expansion - wing weight\")\nview = otv.View(graph)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Furthermore, first order Sobol' indices can also been estimated in a data-driven way using a rank-based sensitivity algorithm.\nIn such a way, the estimation of sensitivity indices does not involve any surrogate model.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"sizeRankSobol = 800\ninputDesignRankSobol = m.distributionX.getSample(sizeRankSobol)\noutputDesignankSobol = m.model(inputDesignRankSobol)\nmyRankSobol = otexp.RankSobolSensitivityAlgorithm(inputDesignRankSobol, outputDesignankSobol)\nindicesrankSobol = myRankSobol.getFirstOrderIndices()\nprint('First order indices:', indicesrankSobol)\ngraph = myRankSobol.draw()\ngraph.setTitle(\"Sobol indices by rank-based estimation - wing weight\")\nview = otv.View(graph)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
Sobol' sensitivity indices using rank-based algorithm
=====================================================
"""

import openturns as ot
import openturns.experimental as otexp
import openturns.viewer as viewer
from openturns.usecases import ishigami_function

# %%
# In this example we are going to compute global sensitivity indices in a data driven framework.
# For that purpose, we are using the rank-based algorithm which provides the first order Sobol' indices.
# We present the method on the :ref:`Ishigami function<use-case-ishigami>`.

ot.Log.Show(ot.Log.NONE)

# %%
# Definition of the model
# -----------------------
#
# We load the model from the usecases module.
im = ishigami_function.IshigamiModel()

# %%
# We generate an input sample of size 500 (and dimension 3).
size = 500
ot.RandomGenerator.SetSeed(10)
X = im.distributionX.getSample(size)

# %%
# We compute the output by applying the Ishigami model to the input sample.
Y = im.model(X)

# %%
# Estimate Sobol' first order indices via rank-based algorithm.
mySobol = otexp.RankSobolSensitivityAlgorithm(X, Y)
indices = mySobol.getFirstOrderIndices()
print('First order indices:', indices)

# %%
# Draw Sobol' indices.
#
# Options for confidence interval estimation can be defined.
ot.ResourceMap.SetAsUnsignedInteger('SobolIndicesAlgorithm-DefaultBootstrapSize', 200)
ot.ResourceMap.SetAsScalar('RankSobolSensitivityAlgorithm-DefaultBootstrapSampleRatio', 0.85)

# %%
# if SobolIndicesAlgorithm-DefaultBootstrapSize > 1, the draw() method will call bootstrap method to compute the confidence intervals.

graph = mySobol.draw()
graph.setTitle("Sobol' indices")
view = viewer.View(graph)

print('confidence intervals:', mySobol.getFirstOrderIndicesInterval())

# %%
# It is possible that Sobol' indices estimates take negative values, that is inconsistent with the theory. Therefore, a larger number of samples is required to get consistent indices.
Binary file not shown.
Binary file modified openturns/master/_images/design_experiment-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/design_experiment-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/monte_carlo_moments-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/monte_carlo_simulation-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/openturns-DiscreteMarkovChain-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/sphere_sampling-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_chaboche_009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_flooding_005.png
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_flooding_006.png
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_flooding_011.png
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_flooding_014.png
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_flooding_016.png
Binary file modified openturns/master/_images/sphx_glr_plot_calibration_flooding_018.png
Binary file modified openturns/master/_images/sphx_glr_plot_create_random_doe_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_ego_003.png
Binary file modified openturns/master/_images/sphx_glr_plot_ego_005.png
Binary file modified openturns/master/_images/sphx_glr_plot_ego_009.png
Binary file modified openturns/master/_images/sphx_glr_plot_generate_chaboche_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_generate_chaboche_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_generate_flooding_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_generate_flooding_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_ifs_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_ifs_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_ifs_003.png
Binary file modified openturns/master/_images/sphx_glr_plot_ifs_004.png
Binary file modified openturns/master/_images/sphx_glr_plot_ifs_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_optimal_lhs_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_optimal_lhs_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_optimization_dlib_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_optimization_dlib_003.png
Binary file modified openturns/master/_images/sphx_glr_plot_pce_design_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_pce_design_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_003.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_004.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_005.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_006.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_007.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_008.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_009.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_010.png
Binary file modified openturns/master/_images/sphx_glr_plot_plot_design_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_probabilistic_design_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_probabilistic_design_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_ancova_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_ancova_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_fast_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_fast_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_fast_thumb.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_sobol_001.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_sobol_002.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_sobol_003.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_sobol_004.png
Binary file modified openturns/master/_images/sphx_glr_plot_sensitivity_sobol_thumb.png
Binary file modified openturns/master/_images/use_case_flood_model-4.png
Binary file modified openturns/master/_images/use_case_flood_model-5.png
Binary file modified openturns/master/_images/use_case_flood_model-6.png
Binary file modified openturns/master/_images/use_case_flood_model-7.png
Binary file modified openturns/master/_images/use_case_flood_model-8.png
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Let us plot the posterior density.

.. rst-class:: sphx-glr-timing

**Total running time of the script:** (0 minutes 12.024 seconds)
**Total running time of the script:** (0 minutes 13.233 seconds)


.. _sphx_glr_download_auto_calibration_bayesian_calibration_plot_gibbs.py:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ Plot posterior marginal plots only as prior cannot be drawn meaningfully.

.. rst-class:: sphx-glr-timing

**Total running time of the script:** (0 minutes 5.445 seconds)
**Total running time of the script:** (0 minutes 5.731 seconds)


.. _sphx_glr_download_auto_calibration_bayesian_calibration_plot_rwmh_python_distribution.py:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Computation times
=================
**00:22.266** total execution time for 7 files **from auto_calibration/bayesian_calibration**:
**00:24.024** total execution time for 7 files **from auto_calibration/bayesian_calibration**:

.. container::

Expand All @@ -33,23 +33,23 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_gibbs.py` (``plot_gibbs.py``)
- 00:12.024
- 00:13.233
- 0.0
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_rwmh_python_distribution.py` (``plot_rwmh_python_distribution.py``)
- 00:05.445
- 00:05.731
- 0.0
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_bayesian_calibration_flooding.py` (``plot_bayesian_calibration_flooding.py``)
- 00:01.332
- 00:01.408
- 0.0
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_bayesian_calibration.py` (``plot_bayesian_calibration.py``)
- 00:01.217
- 00:01.209
- 0.0
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_gibbs_simus.py` (``plot_gibbs_simus.py``)
- 00:01.097
- 00:01.188
- 0.0
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_ackley_distribution.py` (``plot_ackley_distribution.py``)
- 00:00.882
- 00:00.961
- 0.0
* - :ref:`sphx_glr_auto_calibration_bayesian_calibration_plot_imh_python_distribution.py` (``plot_imh_python_distribution.py``)
- 00:00.269
- 00:00.294
- 0.0
Loading

0 comments on commit fe87347

Please sign in to comment.