Hướng dẫn salib python example

Python implementations of commonly used sensitivity analysis methods, including Sobol, Morris, and FAST methods. Useful in systems modeling to calculate the effects of model inputs or exogenous factors on outputs of interest.

Supported Methods#

  • Sobol Sensitivity Analysis (Sobol 2001, Saltelli 2002, Saltelli et al. 2010)

  • Method of Morris, including groups and optimal trajectories (Morris 1991, Campolongo et al. 2007)

  • Fourier Amplitude Sensitivity Test (FAST) (Cukier et al. 1973, Saltelli et al. 1999)

  • Random Balance Designs - Fourier Amplitude Sensitivity Test (RBD-FAST) (Tarantola et al. 2006, Elmar Plischke 2010, Tissot et al. 2012)

  • Delta Moment-Independent Measure (Borgonovo 2007, Plischke et al. 2013)

  • Derivative-based Global Sensitivity Measure (DGSM) (Sobol and Kucherenko 2009)

  • Fractional Factorial Sensitivity Analysis (Saltelli et al. 2008)

  • High Dimensional Model Representation (Li et al. 2010)

  • Getting started
    • Installing SALib
    • Installing Prerequisite Software
    • Testing Installation
  • Basics
    • What is Sensitivity Analysis?
    • What is SALib?
    • An Example
    • Another Example
  • Advanced
    • Group sampling (Sobol and Morris methods only)
    • Generating alternate distributions
  • API
    • FAST - Fourier Amplitude Sensitivity Test
    • RBD-FAST - Random Balance Designs Fourier Amplitude Sensitivity Test
    • Method of Morris
    • Sobol’ Sensitivity Analysis
    • Delta Moment-Independent Measure
    • Derivative-based Global Sensitivity Measure (DGSM)
    • Fractional Factorial
    • PAWN Sensitivity Analysis
    • High-Dimensional Model Representation
  • License
  • Authors
  • How to cite SAlib
  • Projects that use SALib
    • Software
    • Blogs
    • Videos
  • Changes
    • [1.4.5]
    • [1.4.0]
    • [1.3.13]
    • [1.3.0]
    • [1.1.0]
    • [1.0.0]
    • [0.7.1]
    • [0.7.0]
    • [0.6.3]
    • [0.6.2]
    • [0.6.0]
    • [0.5.0]
    • [0.4.0]
    • [0.3.0]
    • [0.2.0]
    • [0.1.0]
  • Complete Module Reference
    • SALib package

  • Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Hướng dẫn salib python example
open source python library for sensitivity analysis

November 22, 2021 Category: Python

Table of Contents[Hide][Show]

  • What is SALib?
  • SALib Example - Sobol' Sensitivity Analysis+
    • 1. Importing SALib
    • 2. Model Input
    • 3. Generate Samples and the Model
    • 4. Perform Analysis
    • 5. Plotting
  • Conclusion

Sensitivity analysis is used to determine the impact of a collection of independent factors on a dependent variable under certain conditions.

It is a strong approach for determining how the model’s output is impacted by the model’s inputs in general terms. In this post, I’ll give a quick overview of sensitivity analysis using SALib, a free Python sensitivity analysis package.

A numerical value known as the sensitivity index, frequently represents each input’s sensitivity. There are numerous types of sensitivity indices:

  • First-order indices: calculates the contribution of a single model input to the output variance.
  • Second-order indices: calculates the contribution of two model inputs to output variance.
  • Total-order index: quantifies a model input’s contribution to output variance, encompassing both first-order effects (the input fluctuating alone) and any higher-order interactions.

What is SALib?

SALib is a Python-based open-source toolkit for doing sensitivity assessments. It has a detached workflow, which means it does not interact directly with the mathematical or computational model. Instead, SALib is in charge of producing the model inputs (through one of the sample functions) and computing the sensitivity indices (via one of the analyze functions) from the model outputs.

A typical SALib sensitivity analysis consists of four steps:

  • Determine the model inputs (parameters) and the sample range for each.
  • To create model inputs, run the sample function.
  • Evaluate the model using the generated inputs and save the model results.
  • To compute the sensitivity indices, use the analyze function on the outputs.

Sobol, Morris, and FAST are just a few of the sensitivity analysis methods provided by SALib. Many factors influence which approach is best for a given application, as we’ll see later. For the time being, keep in mind that you only need to utilize two functions, sample and analyze, regardless of whatever technique you employ. We will guide you through a basic example to illustrate how to utilize SALib.

SALib Example – Sobol’ Sensitivity Analysis

In this example, we will examine the Sobol’ sensitivity of the Ishigami function, as shown below. Because of its high nonlinearity and nonmonotonicity, the Ishigami function is widely used to evaluate uncertainty and sensitivity analysis methodologies.

Hướng dẫn salib python example

The steps go as follows:

1. Importing SALib

The first step is to add the required libraries. The sample and analyze functions of SALib are kept distinct in Python modules. Importing the satellite sample and Sobol analyzing functions, for example, is shown below.

We also use the Ishigami function, which is available as a test function in SALib. Finally, we import NumPy as SALib uses it to store model inputs and outputs in a matrix.

Hướng dẫn salib python example

2. Model Input

The model inputs must then be defined. The Ishigami function accepts three inputs: x1, x2, and x3. In SALib, we construct a dict that specifies the number of inputs, their names, and the limits on each input, as seen below.

Hướng dẫn salib python example

3. Generate Samples and the Model

The samples are then generated. We need to create samples using the Saltelli sampler since we are doing a Sobol sensitivity analysis. In this case, param values are a NumPy matrix. We can observe that the matrix is 8000 by 3 by running param values.shape. 8000 samples were created with the Saltelli sampler. The Saltelli sampler creates samples, where N is 1024 (the parameter we provided) and D is 3. (the number of model inputs).

As previously stated, SALib is not engaged in mathematical or computational model evaluation. If the model is written in Python, you will typically loop through each sample input and assess the model:

Hướng dẫn salib python example

The samples can be saved to a text file if the model is not developed in Python:

Hướng dẫn salib python example

Each line in param values.txt represents one model input. The model’s output should be saved to another file in a similar style, with one output on each line. After that, the outputs may be loaded with:

Hướng dẫn salib python example

In this example, we’re going to use the Ishigami function from SALib. These test functions can be evaluated as follows:

Hướng dẫn salib python example

4. Perform Analysis

We can finally compute the sensitivity indices after loading the model results into Python. In this example, we will use sobol.analyze to compute the first, second, and total-order indices.

Hướng dẫn salib python example

Si is a Python dictionary having the keys “S1,” “S2,” “ST,” “S1 conf,” “S2 conf,” and “ST conf.” The _conf keys hold the associated confidence intervals, which are generally set to 95 percent. To output, all indices, use the keyword parameter print to console=True. Alternatively, as illustrated below, we may print the individual values from Si.

Hướng dẫn salib python example

We can see that x1 and x2 have first-order sensitivity, but x3 does not appear to have any first-order impacts.

Hướng dẫn salib python example

If the total-order indices are significantly bigger than the first-order indices, higher-order interactions are most certainly taking place. We can see these higher-order interactions by looking at the second-order indices:

Hướng dẫn salib python example

We can observe that x1 and x3 have significant interactions. After that, the result may be transformed to a Pandas DataFrame for further study.

Hướng dẫn salib python example

5. Plotting

For your convenience, basic charting facilities are provided. The plot() function produces matplotlib axis objects for subsequent manipulation.

Hướng dẫn salib python example

Conclusion

SALib is a sophisticated sensitivity analysis toolkit. Other techniques in SALib include the Fourier Amplitude Sensitivity Test (FAST), Morris Method, and Delta-Moment Independent Measure. While it is a Python library, it is intended to operate with models of any kind.

SALib offers an easy-to-use command-line interface for creating model inputs and assessing model outputs. Check out SALib documentation to learn more.

Hướng dẫn salib python example

About Jay

I am Computer Science Engineer, with an interest in AI and have worked on research projects in startups. I Provide HQ content on future tech.

Reader Interactions

you're currently offline