uncertainpy

Uncertainpy: a Python toolbox for uncertainty quantification and sensitivity analysis, tailored towards computational neuroscience.

https://github.com/simetenn/uncertainpy

Science Score: 33.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
    Links to: frontiersin.org, zenodo.org
  • Committers with academic emails
    1 of 8 committers (12.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.6%) to scientific vocabulary

Keywords

computational-modeling neuroscience python sensitivity-analysis uncertainty-quantification
Last synced: 6 months ago · JSON representation

Repository

Uncertainpy: a Python toolbox for uncertainty quantification and sensitivity analysis, tailored towards computational neuroscience.

Basic Info
Statistics
  • Stars: 228
  • Watchers: 13
  • Forks: 50
  • Open Issues: 27
  • Releases: 0
Topics
computational-modeling neuroscience python sensitivity-analysis uncertainty-quantification
Created almost 11 years ago · Last pushed over 3 years ago
Metadata Files
Readme License

README.md

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Build Status codecov Documentation Status DOI

A python toolbox for uncertainty quantification and sensitivity analysis tailored towards computational neuroscience.

Uncertainpy is a python toolbox for uncertainty quantification and sensitivity analysis tailored towards computational neuroscience.

Uncertainpy is model independent and treats the model as a black box where the model can be left unchanged. Uncertainpy implements both quasi-Monte Carlo methods and polynomial chaos expansions using either point collocation or the pseudo-spectral method. Both of the polynomial chaos expansion methods have support for the rosenblatt transformation to handle dependent input parameters.

Uncertainpy is feature based, i.e., if applicable, it recognizes and calculates the uncertainty in features of the model, as well as the model itself. Examples of features in neuroscience can be spike timing and the action potential shape.

Uncertainpy is tailored towards neuroscience models, and comes with several common neuroscience models and features built in, but new models and features can easily be implemented. It should be noted that while Uncertainpy is tailored towards neuroscience, the implemented methods are general, and Uncertainpy can be used for many other types of models and features within other fields.

Table of contents

Example

Examples for how to use Uncertainpy can be found in the examples folder as well as in the documentation. Here we show an example, found in examples/coffee_cup, where we examine the changes in temperature of a cooling coffee cup that follows Newton’s law of cooling:

img

This equation tells how the temperature img of the coffee cup changes with time img, when it is in an environment with temperature img. img is a proportionality constant that is characteristic of the system and regulates how fast the coffee cup radiates heat to the environment. For simplicity we set the initial temperature to a fixed value, img, and let img and img be uncertain input parameters.

We start by importing the packages we use:

python import uncertainpy as un import numpy as np # For the time array import chaospy as cp # To create distributions from scipy.integrate import odeint # To integrate our equation

To create the model we define a Python function coffee_cup that takes the uncertain parameters kappa and T_env as input arguments. Inside this function we solve our equation by integrating it using scipy.integrate.odeint, before we return the results. The implementation of the model is:

```python

Create the coffee cup model function

def coffeecup(kappa, Tenv): # Initial temperature and time array time = np.linspace(0, 200, 150) # Minutes T_0 = 95 # Celsius

# The equation describing the model
def f(T, time, kappa, T_env):
    return -kappa*(T - T_env)

# Solving the equation by integration.
temperature = odeint(f, T_0, time, args=(kappa, T_env))[:, 0]

# Return time and model output
return time, temperature

```

We could use this function directly in UncertaintyQuantification, but we would like to have labels on the axes when plotting. So we create a Model with the above run function and labels:

```python

Create a model from the coffee_cup function and add labels

model = un.Model(run=coffee_cup, labels=["Time (min)", "Temperature (C)"]) ```

The next step is to define the uncertain parameters. We give the uncertain parameters in the cooling coffee cup model the following distributions:

img

We use Chaospy to create the distributions, and create a parameter dictionary:

```python

Create the distributions

kappadist = cp.Uniform(0.025, 0.075) Tenv_dist = cp.Uniform(15, 25)

Define the parameter dictionary

parameters = {"kappa": kappadist, "Tenv": Tenvdist} ```

We can now calculate the uncertainty and sensitivity using polynomial chaos expansions with point collocation, which is the default option of quantify:

```python

Set up the uncertainty quantification

UQ = un.UncertaintyQuantification(model=model, parameters=parameters)

Perform the uncertainty quantification using

polynomial chaos with point collocation (by default)

data = UQ.quantify() ```

Here you see an example on how the results might look:

Example of results

This plot shows the mean, variance, and 90% prediction interval (A), and the first-order Sobol indices (B), which shows the sensitivity of the model to each parameter, for the cooling coffee cup model. As the mean (blue line) in A shows, the cooling gives rise to an exponential decay in the temperature, towards the temperature of the environment img. From the sensitivity analysis (B) we see that T is most sensitive to img early in the simulation, and to img towards the end of the simulation. This is as expected, since img determines the rate of the cooling, while img determines the final temperature. After about 150 minutes, the cooling is essentially completed, and the uncertainty in T exclusively reflects the uncertainty of img.

Documentation

The documentation for Uncertainpy can be found at http://uncertainpy.readthedocs.io, and the Uncertainpy paper here: Tennøe S, Halnes G and Einevoll GT (2018) Uncertainpy: A Python Toolbox for Uncertainty Quantification and Sensitivity Analysis in Computational Neuroscience. Front. Neuroinform. 12:49. doi: 10.3389/fninf.2018.00049.

Installation

Uncertainpy works with Python 3. Uncertainpy can easily be installed using pip. The minimum install is:

pip install uncertainpy

To install all requirements you can write:

pip install uncertainpy[all]

Specific optional requirements can also be installed, see below for an explanation. Uncertainpy can also be installed by cloning the Github repository:

$ git clone https://github.com/simetenn/uncertainpy
$ cd /path/to/uncertainpy
$ python setup.py install

setup.py are able to install different set of dependencies. For all options run::

$ python setup.py --help

Alternatively, Uncertainpy can be easily installed (minimum install) with conda using conda-forge channel::

$ conda install -c conda-forge uncertainpy

The above installation within a conda environment is only compatible with Python 3.x. By using conda, the installation will solves compatibility issues automatically.

Dependencies

Uncertainpy has the following dependencies:

  • chaospy
  • tqdm
  • h5py
  • multiprocess
  • numpy
  • scipy
  • seaborn
  • matplotlib
  • xvfbwrapper
  • six
  • SALib
  • exdir

These are installed with the minimum install.

xvfbwrapper requires xvfb, which can be installed with:

sudo apt-get install xvfb

Additionally Uncertainpy has a few optional dependencies for specific classes of models and for features of the models.

EfelFeatures

uncertainpy.EfelFeatures requires the Python package

  • efel

which can be installed with:

pip install uncertainpy[efel_features]

or:

pip install efel

NetworkFeatures

uncertainpy.NetworkFeatures requires the Python packages

  • elephant
  • neo
  • quantities

which can be installed with:

pip install uncertainpy[network_features]

or:

pip install elephant, neo, quantities

NeuronModel

uncertainpy.NeuronModel requires the external simulator Neuron (with Python), a simulator for neurons. Neuron must be installed by the user.

NestModel

uncertainpy.NestModel requires the external simulator Nest (with Python), a simulator for network of neurons. Nest must be installed by the user.

Test suite

Uncertainpy comes with an extensive test suite that can be run with the test.py script. For how to use test.py run:

$ python test.py --help

test.py has all dependencies of Uncertainpy in addition to:

  • click

These can be installed with pip:

pip install uncertainpy[tests]

In addition, the following program must be installed:

  • hdf5-tools

Citation

If you use Uncertainpy in your work, please cite: Tennøe S, Halnes G and Einevoll GT (2018) Uncertainpy: A Python Toolbox for Uncertainty Quantification and Sensitivity Analysis in Computational Neuroscience. Front. Neuroinform. 12:49. doi: 10.3389/fninf.2018.00049.

Commit messages

The style mostly used:

API:         an (incompatible) API change
Benchmark:   changes to the benchmark suite
Build:       related to building
Bug:         bug fix
Deprecate:   deprecate something, or remove a deprecated object
Doc:         documentation
[ blank ]:   enhancement
Refactor:    maintenance commit (refactoring, typos, etc.)
Revert:      revert an earlier commit
Style:       fix (whitespace, PEP8)
Test:        addition or modification of tests
Release:     related to releasing
Tool:        development tool or utility
WIP:         Work-in-progress

Owner

  • Name: Simen Tennøe
  • Login: simetenn
  • Kind: user
  • Company: @expertanalytics

Neuroscientist with background from computational astrophysics.

GitHub Events

Total
  • Watch event: 6
  • Issue comment event: 1
  • Pull request event: 2
Last Year
  • Watch event: 6
  • Issue comment event: 1
  • Pull request event: 2

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 1,713
  • Total Committers: 8
  • Avg Commits per committer: 214.125
  • Development Distribution Score (DDS): 0.032
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Simen Tennøe s****n@g****m 1,659
Simen Tennøe s****n@x****o 23
Simen Tennøe s****n@u****m 21
Diego Volpatto v****o@l****r 3
Mikko m****i@t****i 3
Mikkel Elle Lepperød l****k@g****m 2
Cornelius c****r@g****m 1
Sebastian Schmitt s****t@p****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 54
  • Total pull requests: 12
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 13 days
  • Total issue authors: 28
  • Total pull request authors: 8
  • Average comments per issue: 1.06
  • Average comments per pull request: 1.08
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 1
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • simetenn (19)
  • maciej-jedynak (4)
  • tzipperle (3)
  • takafusui (2)
  • moja84 (2)
  • goghino (2)
  • mckinnonm (1)
  • lilianschuster (1)
  • Chaztikov (1)
  • ivan-marroquin (1)
  • GuillaumeGirier (1)
  • DougRDrake (1)
  • desertnaut (1)
  • jmrfox (1)
  • ireneanello (1)
Pull Request Authors
  • schmitts (2)
  • Mikkolehtimaki (2)
  • simetenn (2)
  • dependabot[bot] (2)
  • coschroeder (1)
  • j-zimmermann (1)
  • volpatto (1)
  • CheLamVien (1)
Top Labels
Issue Labels
enhancement (12) bug (8) question (5)
Pull Request Labels
dependencies (2)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 106 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 3
    (may contain duplicates)
  • Total versions: 16
  • Total maintainers: 1
pypi.org: uncertainpy

A python toolbox for uncertainty quantification and sensitivity analysis tailored towards neuroscience models.

  • Versions: 13
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 106 Last month
Rankings
Stargazers count: 4.7%
Forks count: 6.0%
Dependent packages count: 10.1%
Dependent repos count: 11.5%
Average: 11.6%
Downloads: 25.5%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: uncertainpy

Uncertainpy is a python toolbox for uncertainty quantification and sensitivity analysis tailored towards computational neuroscience. Uncertainpy is model independent and treats the model as a black box where the model can be left unchanged. Uncertainpy implements both quasi-Monte Carlo methods and polynomial chaos expansions using either point collocation or the pseudo-spectral method. Both of the polynomial chaos expansion methods have support for the rosenblatt transformation to handle dependent input parameters. Uncertainpy is feature based, i.e., if applicable, it recognizes and calculates the uncertainty in features of the model, as well as the model itself. Examples of features in neuroscience can be spike timing and the action potential shape. Uncertainpy is tailored towards neuroscience models, and comes with several common neuroscience models and features built in, but new models and features can easily be implemented. It should be noted that while Uncertainpy is tailored towards neuroscience, the implemented methods are general, and Uncertainpy can be used for many other types of models and features within other fields.

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.4%
Forks count: 26.3%
Stargazers count: 26.9%
Average: 32.3%
Dependent packages count: 51.6%
Last synced: 6 months ago

Dependencies

binder/requirements.txt pypi
  • chaospy *
  • h5py *
  • matplotlib *
  • multiprocess *
  • numpy *
  • scipy *
  • seaborn *
  • six *
  • tqdm *
  • xvfbwrapper *
examples/paper_figures/paper_requirements.txt pypi
  • Babel ==2.5.3
  • Bottleneck ==1.2.1
  • ConnPlotter ==0.7a0
  • Cython ==0.27.3
  • Flask ==0.12.2
  • Flask-Cors ==3.0.3
  • Jinja2 ==2.10
  • MarkupSafe ==1.0
  • NEURON ==7.5
  • Pillow ==5.0.0
  • PyNEST ==2.14.0
  • PySocks ==1.6.7
  • PyWavelets ==0.5.2
  • PyYAML ==3.12
  • Pygments ==2.2.0
  • QtAwesome ==0.4.4
  • QtPy ==1.3.1
  • SALib ==1.1.3
  • SQLAlchemy ==1.2.1
  • Send2Trash ==1.4.2
  • Sphinx ==1.6.6
  • Topology ==2.14.0
  • Werkzeug ==0.14.1
  • XlsxWriter ==1.0.2
  • alabaster ==0.7.10
  • anaconda-client ==1.6.9
  • anaconda-navigator ==1.7.0
  • anaconda-project ==0.8.2
  • asn1crypto ==0.24.0
  • astroid ==1.6.1
  • astropy ==2.0.3
  • attrs ==17.4.0
  • backports.shutil-get-terminal-size ==1.0.0
  • beautifulsoup4 ==4.6.0
  • bitarray ==0.8.1
  • bkcharts ==0.2
  • blaze ==0.11.3
  • bleach ==2.1.2
  • bokeh ==0.12.13
  • boto ==2.48.0
  • certifi ==2018.4.16
  • cffi ==1.11.4
  • chaospy ==2.3.2
  • chardet ==3.0.4
  • click ==6.7
  • cloudpickle ==0.5.2
  • clyent ==1.2.2
  • colorama ==0.3.9
  • conda ==4.5.4
  • conda-build ==3.4.1
  • conda-verify ==2.0.0
  • contextlib2 ==0.5.5
  • coverage ==4.5.1
  • cryptography ==2.1.4
  • cycler ==0.10.0
  • cytoolz ==0.9.0
  • dask ==0.16.1
  • datashape ==0.5.4
  • decorator ==4.2.1
  • dill ==0.2.7.1
  • distributed ==1.20.2
  • docutils ==0.14
  • efel ==2.13.13
  • elephant ==0.5.0
  • entrypoints ==0.2.3
  • et-xmlfile ==1.0.1
  • exdir ==0.3.1
  • fastcache ==1.0.2
  • filelock ==2.0.13
  • gevent ==1.2.2
  • glob2 ==0.6
  • gmpy2 ==2.0.8
  • greenlet ==0.4.12
  • h5py ==2.7.1
  • heapdict ==1.0.0
  • html5lib ==1.0.1
  • idna ==2.6
  • imageio ==2.2.0
  • imagesize ==0.7.1
  • ipykernel ==4.8.0
  • ipython ==6.2.1
  • ipython-genutils ==0.2.0
  • ipywidgets ==7.1.1
  • isort ==4.2.15
  • itsdangerous ==0.24
  • jdcal ==1.3
  • jedi ==0.11.1
  • jsonschema ==2.6.0
  • jupyter ==1.0.0
  • jupyter-client ==5.2.2
  • jupyter-console ==5.2.0
  • jupyter-core ==4.4.0
  • jupyterlab ==0.31.5
  • jupyterlab-launcher ==0.10.2
  • lazy-object-proxy ==1.3.1
  • llvmlite ==0.21.0
  • locket ==0.2.0
  • lxml ==4.1.1
  • matplotlib ==2.1.2
  • mccabe ==0.6.1
  • mistune ==0.8.3
  • mpmath ==1.0.0
  • msgpack-python ==0.5.1
  • multipledispatch ==0.4.9
  • multiprocess ==0.70.5
  • navigator-updater ==0.1.0
  • nbconvert ==5.3.1
  • nbformat ==4.4.0
  • neo ==0.6.1
  • networkx ==2.1
  • nltk ==3.2.5
  • nose ==1.3.7
  • notebook ==5.4.0
  • numba ==0.36.2
  • numexpr ==2.6.4
  • numpy ==1.14.0
  • numpydoc ==0.7.0
  • odo ==0.5.1
  • olefile ==0.45.1
  • openpyxl ==2.4.10
  • packaging ==16.8
  • pandas ==0.22.0
  • pandocfilters ==1.4.2
  • parso ==0.1.1
  • partd ==0.3.8
  • path.py ==10.5
  • pathlib2 ==2.3.0
  • patsy ==0.5.0
  • pep8 ==1.7.1
  • pexpect ==4.3.1
  • pickleshare ==0.7.4
  • pip ==9.0.1
  • pkginfo ==1.4.1
  • pluggy ==0.6.0
  • ply ==3.10
  • prompt-toolkit ==1.0.15
  • psutil ==5.4.3
  • ptyprocess ==0.5.2
  • py ==1.5.2
  • pyOpenSSL ==17.5.0
  • pycodestyle ==2.3.1
  • pycosat ==0.6.3
  • pycparser ==2.18
  • pycrypto ==2.6.1
  • pycurl ==7.43.0.1
  • pyflakes ==1.6.0
  • pylint ==1.8.2
  • pyodbc ==4.0.22
  • pyparsing ==2.2.0
  • pytest ==3.3.2
  • python-dateutil ==2.6.1
  • pytz ==2017.3
  • pyzmq ==16.0.3
  • qtconsole ==4.3.1
  • quantities ==0.12.1
  • requests ==2.18.4
  • rope ==0.10.7
  • ruamel-yaml ==0.15.35
  • scikit-image ==0.13.1
  • scikit-learn ==0.19.1
  • scipy ==1.0.0
  • seaborn ==0.8.1
  • setuptools ==38.4.0
  • simplegeneric ==0.8.1
  • singledispatch ==3.4.0.3
  • six ==1.11.0
  • snowballstemmer ==1.2.1
  • sortedcollections ==0.5.3
  • sortedcontainers ==1.5.9
  • sphinxcontrib-websupport ==1.0.1
  • spyder ==3.2.6
  • statsmodels ==0.8.0
  • sympy ==1.1.1
  • tables ==3.4.2
  • tblib ==1.3.2
  • terminado ==0.8.1
  • testpath ==0.3.1
  • toolz ==0.9.0
  • tornado ==4.5.3
  • tqdm ==4.23.4
  • traitlets ==4.3.2
  • typing ==3.6.2
  • unicodecsv ==0.14.1
  • urllib3 ==1.22
  • wcwidth ==0.1.7
  • webencodings ==0.5.1
  • wheel ==0.30.0
  • widgetsnbextension ==3.1.0
  • wrapt ==1.10.11
  • xlrd ==1.1.0
  • xlwt ==1.3.0
  • xvfbwrapper ==0.2.9
  • zict ==0.1.3