Skip to main content

A Python library providing parameter screening of computational models using the Morris method of Elementary Effects or its extension of Efficient Elementary Effects by Cuntz, Mai et al. (Water Res Research, 2015).

Project description

pyeee - Parameter screening of computational models

A Python library for parameter screening of computational models using Morris' method of Elementary Effects or its extension of Efficient/Sequential Elementary Effects by Cuntz, Mai et al. (Water Res Research, 2015).

DOI PyPI version License Build Status Coverage Status Documentation Status

About pyeee

pyeee is a Python library for performing parameter screening of computational models. It uses Morris' method of Elementary Effects and also its extension of Efficient or Sequential Elementary Effects published of

Cuntz, Mai et al. (2015)
Computationally inexpensive identification of noninformative model parameters by sequential screening
Water Resources Research 51, 6417-6441, doi:10.1002/2015WR016907.

The package uses several functions of the JAMS Python package https://github.com/mcuntz/jams_python
The JAMS package and hesseflux are synchronised irregularly.

pyeee can be used with Python functions but also with external programs, using for example partialwrap. Function evaluation can be distributed with Python's multiprocessing or via MPI.

Documentation

The complete documentation for pyeee is available from Read The Docs.

http://pyeee.readthedocs.org/en/latest/

Quick usage guide

Simple Python function

Consider the Ishigami-Homma function: y = sin(x_0) + a*sin(x_1)^2 + b*x_2^4*sin(x_0).

Taking a = b = 1 gives:

    import numpy as np
    def ishigami1(x):
       return np.sin(x[0]) + np.sin(x[1])**2 + x[2]**4 * np.sin(x[0])

The three paramters x_0, x_1, x_2 follow uniform distributions between -pi and +pi.

Morris' Elementary Effects can then be calculated like:

    npars = 3
    # lower boundaries
    lb = np.ones(npars) * (-np.pi)
    # upper boundaries
    ub = np.ones(npars) * np.pi

    # Elementary Effects
    from pyeee import ee
    np.random.seed(seed=1023) # for reproducibility of examples
    out = ee(ishigami1, lb, ub, 10)

which gives the Elementary Effects ($\mu*$):

    # mu*
    print("{:.1f} {:.1f} {:.1f}".format(*out[:,0]))
    # gives: 173.1 0.6 61.7

Sequential Elementary Effects distinguish between informative and uninformative parameters using several times Morris' Elementary Effects:

    # screen
    from pyeee import eee
    np.random.seed(seed=1023) # for reproducibility of examples
    out = eee(ishigami1, lb, ub, ntfirst=10)

which returns a logical ndarray with True for the informative parameters and False for the uninformative parameters:

    print(out)
    [ True False  True]

Python function with extra parameters

The function for pyeee must be of the form func(x). Use Python's partial from the functools module to pass other function parameters.

For example pass the parameters $a$ and $b$ to the Ishigami-Homma function.

    import numpy as np
    from pyeee import ee
    from functools import partial

    def ishigami(x, a, b):
       return np.sin(x[0]) + a * np.sin(x[1])**2 + b * x[2]**4 * np.sin(x[0])

    def call_func_ab(func, a, b, x):
       return func(x, a, b)

    # Partialise function with fixed parameters
    a = 0.5
    b = 2.0
    func  = partial(call_func_ab, ishigami, a, b)
    npars = 3

    # lower boundaries
    lb = np.ones(npars) * (-np.pi)
    # upper boundaries
    ub = np.ones(npars) * np.pi

    # Elementary Effects
    np.random.seed(seed=1023) # for reproducibility of examples
    out = ee(func, lb, ub, 10)

Figuratively speaking, partial passes a and b to the function call_func_ab already during definition so that pyeee can then simply call it as func(x), so that x is passed to call_func_ab as well.

Function wrappers

We recommend to use the package partialwrap, which provides wrappers to use with partial.

    from pyeee.utils import func_wrapper
    args = [a, b]
    kwargs = {}
    func = partial(func_wrapper, ishigami, args, kwargs)

    # screen
    out = eee(func, lb, ub)

There are wrappers to use with Python functions with or without masking parameters, as well as wrappers for external programs.

See the documentation for details:

http://pyeee.readthedocs.org/en/latest/

Installation

The easiest way to install is via pip::

pip install pyeee

See the installation instructions in the documentation for more information.

Requirements:

License

pyeee is distributed under the MIT License.
See the LICENSE file for details.

Copyright (c) 2013-2021 Matthias Cuntz, Juliane Mai

The project structure is based on a template provided by Sebastian Müller.

Contributing to pyeee

Users are welcome to submit bug reports, feature requests, and code contributions to this project through GitHub.

More information is available in the Contributing guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyeee-3.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyeee-3.0-py2.py3-none-any.whl (13.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyeee-3.0.tar.gz.

File metadata

  • Download URL: pyeee-3.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7

File hashes

Hashes for pyeee-3.0.tar.gz
Algorithm Hash digest
SHA256 f9130f1e33c0035fb06de3b15e8285bdbf1eeea41cafcfc50be7d0f3bb857c34
MD5 f5b6b2b20de106b8c51447fb7faa0016
BLAKE2b-256 064070eebb087edbd17cac874947ae6c154e87df233719ff4734c05390d94086

See more details on using hashes here.

File details

Details for the file pyeee-3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyeee-3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7

File hashes

Hashes for pyeee-3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 96d1a9ff3e5006d22ebb58649199f8f0d495203151ea862fb7aea8627e8c9f8c
MD5 689625200c5ac7509463ee1a596fb2c9
BLAKE2b-256 fc63a14d58e10c6063c02112dd9c2557fe4e4c144c8d2a0e06c842bd01f7f5d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page