SALib package#

Subpackages#

Module contents#

class SALib.ProblemSpec(*args, **kwargs)[source]#

Bases: dict

Dictionary-like object representing an SALib Problem specification.

property analysis#
analyze(func, *args, **kwargs)[source]#

Analyze sampled results using given function.

Parameters
  • func (function,) – Analysis method to use. The provided function must accept the problem specification as the first parameter, X values if needed, Y values, and return a numpy array.

  • *args (list,) – Additional arguments to be passed to func

  • nprocs (int,) – If specified, attempts to parallelize model evaluations

  • **kwargs (dict,) – Additional keyword arguments passed to func

Returns

self

Return type

ProblemSpec object

analyze_parallel(func, *args, nprocs=None, **kwargs)[source]#

Analyze sampled results using the given function in parallel.

Parameters
  • func (function,) – Analysis method to use. The provided function must accept the problem specification as the first parameter, X values if needed, Y values, and return a numpy array.

  • *args (list,) – Additional arguments to be passed to func

  • nprocs (int,) – Number of processors to use. Capped to the number of outputs or available processors.

  • **kwargs (dict,) – Additional keyword arguments passed to func

Returns

self

Return type

ProblemSpec object

evaluate(func, *args, **kwargs)[source]#

Evaluate a given model.

Parameters
  • func (function,) – Model, or function that wraps a model, to be run/evaluated. The provided function is required to accept a numpy array of inputs as its first parameter and must return a numpy array of results.

  • *args (list,) – Additional arguments to be passed to func

  • nprocs (int,) – If specified, attempts to parallelize model evaluations

  • **kwargs (dict,) – Additional keyword arguments passed to func

Returns

self

Return type

ProblemSpec object

evaluate_distributed(func, *args, nprocs=1, servers=None, verbose=False, **kwargs)[source]#

Distribute model evaluation across a cluster.

Usage Conditions: * The provided function needs to accept a numpy array of inputs as

its first parameter

  • The provided function must return a numpy array of results

Parameters
  • func (function,) – Model, or function that wraps a model, to be run in parallel

  • nprocs (int,) – Number of processors to use for each node. Defaults to 1.

  • servers (list[str] or None,) – IP addresses or alias for each server/node to use.

  • verbose (bool,) – Display job execution statistics. Defaults to False.

  • *args (list,) – Additional arguments to be passed to func

  • **kwargs (dict,) – Additional keyword arguments passed to func

Returns

self

Return type

ProblemSpec object

evaluate_parallel(func, *args, nprocs=None, **kwargs)[source]#

Evaluate model locally in parallel.

All detected processors will be used if nprocs is not specified.

Parameters
  • func (function,) – Model, or function that wraps a model, to be run in parallel. The provided function needs to accept a numpy array of inputs as its first parameter and must return a numpy array of results.

  • nprocs (int,) – Number of processors to use. Capped to the number of available processors.

  • *args (list,) – Additional arguments to be passed to func

  • **kwargs (dict,) – Additional keyword arguments passed to func

Returns

self

Return type

ProblemSpec object

heatmap(metric: str = None, index: str = None, title: str = None, ax=None)[source]#

Plot results as a heatmap.

Parameters
  • metric (str or None, name of output to analyze (display all if None)) –

  • index (str or None, name of index to plot, dependent on what) – analysis was conducted (ST, S1, etc; displays all if None)

  • title (str, title of plot to use (defaults to the same as metric)) –

  • ax (axes object, matplotlib axes object to use for plot.) – Creates a new figure if not provided.

Returns

ax

Return type

matplotlib axes object

plot()[source]#

Plot results as a bar chart.

Returns

axes

Return type

matplotlib axes object

property results#
sample(func, *args, **kwargs)[source]#

Create sample using given function.

Parameters
  • func (function,) – Sampling method to use. The given function must accept the SALib problem specification as the first parameter and return a numpy array.

  • *args (list,) – Additional arguments to be passed to func

  • **kwargs (dict,) – Additional keyword arguments passed to func

Returns

self

Return type

ProblemSpec object

property samples#
set_results(results: ndarray)[source]#

Set previously available model results.

set_samples(samples: ndarray)[source]#

Set previous samples used.

to_df()[source]#

Convert results to Pandas DataFrame.