Skip to content

Commit

Permalink
Merge pull request #290 from elfi-dev/dev
Browse files Browse the repository at this point in the history
Release v. 0.7.3
  • Loading branch information
hpesonen authored Aug 30, 2018
2 parents ce02414 + 269ac4f commit ff25fcb
Show file tree
Hide file tree
Showing 28 changed files with 560 additions and 167 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ ENV
*.swo
*.swp

# Compiled stuff
bdm
elfi/examples/cpp/bdm
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ matrix:
before_install:
- mkdir -p /Users/travis/.matplotlib
- "echo 'backend: TkAgg' > /Users/travis/.matplotlib/matplotlibrc"
- brew update
- brew upgrade python
- pip3 install virtualenv
- virtualenv py3env -p python3
- source py3env/bin/activate
- travis_retry wget "http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" -O miniconda.sh
- "bash miniconda.sh -b -p $HOME/miniconda"
- "export PATH=$HOME/miniconda/bin:$PATH"
- "conda create -y -n elfi python=3.6 scipy"
- "source activate elfi"

cache: pip

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

0.7.3 (2018-08-30)
------------------
- Fix bug in plot_pairs which crashes in case of 1 parameter
- Fix bug in plot_marginals which outputs empty plots in case where we have parameter more than 5
- Fix crashing summary and plots for samples with multivariate priors
- Add progress bar for inference methods
- Add method save to Sample objects
- Add support for giving seed to `generate`
- Implement elfi.plot_params_vs_node for plotting parameters vs. node output

0.7.2 (2018-06-20)
------------------
- Added support for kwargs in elfi.set_client
Expand Down
16 changes: 5 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
FROM python:3.6
FROM ubuntu:bionic

RUN apt-get update && apt-get install -y graphviz
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y graphviz make python3-scipy jupyter python3-matplotlib
RUN pip3 install graphviz

WORKDIR /elfi
ADD . /elfi

RUN pip install numpy graphviz
RUN pip install -e .
RUN pip install -r requirements-dev.txt

# matplotlib unable to show figures
RUN mkdir -p /root/.config/matplotlib
RUN echo "backend : Agg" >> /root/.config/matplotlib/matplotlibrc

CMD ["/bin/bash"]
RUN pip3 install -e .
RUN pip3 install -r requirements-dev.txt
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**Version 0.7.2 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
**Version 0.7.3 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).

**NOTE:** For the time being NetworkX 2 is incompatible with ELFI.

Expand All @@ -13,10 +13,10 @@ ELFI - Engine for Likelihood-Free Inference

<img src="https://cloud.githubusercontent.com/assets/1233418/20178983/6e22ee44-a75c-11e6-8345-5934b55b9dc6.png" width="15%" align="right"></img>

ELFI is a statistical software package written in Python for likelihood-free inference (LFI) such as Approximate
Bayesian Computation ([ABC](https://en.wikipedia.org/wiki/Approximate_Bayesian_computation)).
The term LFI refers to a family of inference methods that replace the use of the likelihood function with a data
generating simulator function. ELFI features an easy to use generative modeling syntax and supports parallelized
ELFI is a statistical software package written in Python for likelihood-free inference (LFI) such as Approximate
Bayesian Computation ([ABC](https://en.wikipedia.org/wiki/Approximate_Bayesian_computation)).
The term LFI refers to a family of inference methods that replace the use of the likelihood function with a data
generating simulator function. ELFI features an easy to use generative modeling syntax and supports parallelized
inference out of the box.

Currently implemented LFI methods:
Expand All @@ -32,8 +32,8 @@ ELFI also integrates tools for visualization, model comparison, diagnostics and

See examples under [notebooks](https://github.com/elfi-dev/notebooks) to get started. Full
documentation can be found at http://elfi.readthedocs.io/. Limited user-support may be
asked from elfi-support.at.hiit.fi, but the
[Gitter chat](https://gitter.im/elfi-dev/elfi?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
asked from elfi-support.at.hiit.fi, but the
[Gitter chat](https://gitter.im/elfi-dev/elfi?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
is preferable.


Expand All @@ -48,9 +48,9 @@ pip install elfi
or on some platforms using Python 3 specific syntax:
```
pip3 install elfi
```
```

Note that in some environments you may need to first install `numpy` with
Note that in some environments you may need to first install `numpy` with
`pip install numpy`. This is due to our dependency to `GPy` that uses `numpy` in its installation.

### Optional dependencies
Expand All @@ -77,7 +77,7 @@ pip install elfi

### Docker container

A simple Dockerfile for command-line interface is also provided. Please see [Docker documentation](https://docs.docker.com/).
A simple Dockerfile for command-line interface is also provided. This is especially suitable for running tests. Please see [Docker documentation](https://docs.docker.com/) for details.

```
git clone --depth 1 https://github.com/elfi-dev/elfi.git
Expand All @@ -88,11 +88,11 @@ docker run -it elfi

### Potential problems with installation

ELFI depends on several other Python packages, which have their own dependencies.
ELFI depends on several other Python packages, which have their own dependencies.
Resolving these may sometimes go wrong:
- If you receive an error about missing `numpy`, please install it first.
- If you receive an error about `yaml.load`, install `pyyaml`.
- On OS X with Anaconda virtual environment say `conda install python.app` and then use
- On OS X with Anaconda virtual environment say `conda install python.app` and then use
`pythonw` instead of `python`.
- Note that ELFI requires Python 3.5 or greater so try `pip3 install elfi`.
- Make sure your Python installation meets the versions listed in `requirements.txt`.
Expand Down
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Below is the API for creating generative models.

.. autosummary::
elfi.draw
elfi.plot_params_vs_node

Inference API
-------------
Expand Down Expand Up @@ -177,6 +178,8 @@ Modelling API classes

.. autofunction:: elfi.draw

.. autofunction:: elfi.plot_params_vs_node

.. This would show undocumented members :undoc-members:
Expand Down
3 changes: 2 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ means the current folder.
Docker container
----------------

A simple Dockerfile for command-line interface is also provided. Please see `Docker documentation`_.
A simple Dockerfile for command-line interface is also provided. This is especially suitable
for running tests. Please see `Docker documentation`_ for details.

.. _Docker documentation: https://docs.docker.com/

Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ for the standard deviation ``sigma``. All distributions from
For likelihood-free models we typically need to define a simulator and
summary statistics for the data. As an example, lets define the
simulator as 30 draws from a Gaussian distribution with a given mean and
standard deviation. Let's use mean and variance as our summaries:
standard deviation. Lets use mean and variance as our summaries:

.. code:: ipython3
Expand Down Expand Up @@ -125,7 +125,7 @@ posterior using threshold value 0.5:
Let's plot also the marginal distributions for the parameters:
Lets plot also the marginal distributions for the parameters:

.. code:: ipython3
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/BOLFI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ initialize the GP model with a dictionary of previous results by giving

The BOLFI class can now try to ``fit`` the surrogate model (the GP) to
the relationship between parameter values and the resulting
discrepancies. We'll request only 100 evidence points (including the
discrepancies. Well request only 100 evidence points (including the
``initial_evidence`` defined above).

.. code:: ipython3
Expand Down Expand Up @@ -263,7 +263,7 @@ is a sophisticated algorithm, and in some cases one may get warnings
about diverged proposals, which are signs that `something may be wrong
and should be
investigated <http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup>`__.
It is good to understand the cause of these warnings although they don't
It is good to understand the cause of these warnings although they dont
automatically mean that the results are unreliable. You could try
rerunning the ``sample`` method with a higher target probability
``target_prob`` during adaptation, as its default 0.6 may be inadequate
Expand Down
46 changes: 23 additions & 23 deletions docs/usage/external.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ If your simulator or other operations are implemented in a programming
language other than Python, you can still use ELFI. This notebook
briefly demonstrates how to do this in three common scenarios:

- External executable (written e.g. in C++ or a shell script)
- External executable (written e.g. in C++ or a shell script)
- R function
- MATLAB function

Let's begin by importing some libraries that we will be using:
Lets begin by importing some libraries that we will be using:

.. code:: ipython3
Expand Down Expand Up @@ -43,7 +43,7 @@ introduced in this tutorial.

We demonstrate here how to wrap executables as ELFI nodes. We will first
use ``elfi.tools.external_operation`` tool to wrap executables as a
Python callables (function). Let's first investigate how it works with a
Python callables (function). Lets first investigate how it works with a
simple shell ``echo`` command:

.. code:: ipython3
Expand All @@ -64,7 +64,7 @@ simple shell ``echo`` command:
The placeholders for arguments in the command string are just Python's
The placeholders for arguments in the command string are just Pythons
```format strings`` <https://docs.python.org/3/library/string.html#formatstrings>`__.

Currently ``echo_sim`` only accepts scalar arguments. In order to work
Expand Down Expand Up @@ -103,16 +103,16 @@ Complex external operations :math:`-` case BDM
----------------------------------------------

To provide a more realistic example of external operations, we will
consider the Birth-Death-Mutation (BDM) model used in `*Lintusaari at al
2016* <https://doi.org/10.1093/sysbio/syw077>`__ *[1]*.
consider the Birth-Death-Mutation (BDM) model used in `Lintusaari at al
2016 <https://doi.org/10.1093/sysbio/syw077>`__ *[1]*.

Birth-Death-Mutation process
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We will consider here the Birth-Death-Mutation process simulator
introduced in *Tanaka et al 2006 [2]* for the spread of Tuberculosis.
The simulator outputs a count vector where each of its elements
represents a "mutation" of the disease and the count describes how many
represents a mutation of the disease and the count describes how many
are currently infected by that mutation. There are three rates and the
population size:

Expand All @@ -128,8 +128,8 @@ population size:
It is assumed that the susceptible population is infinite, the hosts
carry only one mutation of the disease and transmit that mutation
onward. A more accurate description of the model can be found from the
original paper or e.g. `*Lintusaari at al
2016* <https://doi.org/10.1093/sysbio/syw077>`__ *[1]*.
original paper or e.g. `Lintusaari at al
2016 <https://doi.org/10.1093/sysbio/syw077>`__ *[1]*.

.. For documentation
Expand All @@ -140,8 +140,8 @@ original paper or e.g. `*Lintusaari at al

This simulator cannot be implemented effectively with vectorized
operations so we have implemented it with C++ that handles loops
efficiently. We will now reproduce Figure 6(a) in `*Lintusaari at al
2016* <https://doi.org/10.1093/sysbio/syw077>`__ *[2]* with ELFI. Let's
efficiently. We will now reproduce Figure 6(a) in `Lintusaari at al
2016 <https://doi.org/10.1093/sysbio/syw077>`__ *[2]* with ELFI. Lets
start by defining some constants:

.. code:: ipython3
Expand All @@ -154,7 +154,7 @@ start by defining some constants:
# The zeros are to make the observed population vector have length N
y_obs = np.array([6, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype='int16')
Let's build the beginning of a new model for the birth rate
Lets build the beginning of a new model for the birth rate
:math:`\alpha` as the only unknown

.. code:: ipython3
Expand Down Expand Up @@ -214,8 +214,8 @@ thousands of simulations. We will also here redirect the output to a
file and then read the file into a numpy array.

This is just one possibility among the many to implement this. The most
efficient would be to write a native Python module with C++ but it's
beyond the scope of this article. So let's work through files which is a
efficient would be to write a native Python module with C++ but its
beyond the scope of this article. So lets work through files which is a
fairly common situation especially with existing software.

.. code:: ipython3
Expand Down Expand Up @@ -265,7 +265,7 @@ fairly common situation especially with existing software.
process_result=process_result,
stdout=False)
Now let's replace the echo simulator with this. To create unique but
Now lets replace the echo simulator with this. To create unique but
informative filenames, we ask ELFI to provide the operation some meta
information. That will be available under the ``meta`` keyword (see the
``prepare_inputs`` function above):
Expand Down Expand Up @@ -306,9 +306,9 @@ Completing the BDM model
~~~~~~~~~~~~~~~~~~~~~~~~

We are now ready to finish up the BDM model. To reproduce Figure 6(a) in
`*Lintusaari at al 2016* <https://doi.org/10.1093/sysbio/syw077>`__
*[2]*, let's add different summaries and discrepancies to the model and
run the inference for each of them:
`Lintusaari at al 2016 <https://doi.org/10.1093/sysbio/syw077>`__ *[2]*,
lets add different summaries and discrepancies to the model and run the
inference for each of them:

.. code:: ipython3
Expand Down Expand Up @@ -421,7 +421,7 @@ the functionality of R from within Python. You can install it with
``pip install rpy2``.

Here we demonstrate how to calculate the summary statistics used in the
ELFI tutorial (autocovariances) using R's ``acf`` function for the MA2
ELFI tutorial (autocovariances) using Rs ``acf`` function for the MA2
model.

.. code:: ipython3
Expand All @@ -436,7 +436,7 @@ model.

.. _issue: https://github.com/ContinuumIO/anaconda-issues/issues/152

Let's create a Python function that wraps the R commands (please see the
Lets create a Python function that wraps the R commands (please see the
documentation of `rpy2 <http://rpy2.readthedocs.io>`__ for details):

.. code:: ipython3
Expand Down Expand Up @@ -600,7 +600,7 @@ Replace the summaries S1 and S2 with our R autocovariance function.
Finally, don't forget to quit the MATLAB session:
Finally, dont forget to quit the MATLAB session:

.. code:: ipython3
Expand All @@ -625,6 +625,6 @@ References
Kaski, Jukka Corander; Fundamentals and Recent Developments in
Approximate Bayesian Computation. Syst Biol 2017; 66 (1): e66-e82.
doi: 10.1093/sysbio/syw077
- [2] Tanaka, Mark M., et al. "Using approximate Bayesian computation
to estimate tuberculosis transmission parameters from genotype data."
- [2] Tanaka, Mark M., et al. Using approximate Bayesian computation
to estimate tuberculosis transmission parameters from genotype data.
Genetics 173.3 (2006): 1511-1520.
Loading

0 comments on commit ff25fcb

Please sign in to comment.