Skip to content

Commit

Permalink
Preparing version v. 0.7.3 (#289)
Browse files Browse the repository at this point in the history
* Bump version

* update api-docs

* update sphinx-convert docs
  • Loading branch information
hpesonen committed Aug 30, 2018
1 parent 33a7a88 commit 269ac4f
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 79 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Changelog
=========

dev
---
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
Expand Down
22 changes: 11 additions & 11 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 Down Expand Up @@ -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
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.
14 changes: 7 additions & 7 deletions docs/usage/parallelization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inference via different clients. Currently ELFI includes three clients:
- ``elfi.clients.native`` (activated by default): does not parallelize
but makes it easy to test and debug your code.
- ``elfi.clients.multiprocessing``: basic local parallelization using
Python's built-in multiprocessing library
Pythons built-in multiprocessing library
- ``elfi.clients.ipyparallel``:
`ipyparallel <http://ipyparallel.readthedocs.io/>`__ based client
that can parallelize from multiple cores up to a distributed cluster.
Expand All @@ -24,15 +24,15 @@ This tutorial shows how to activate and use the ``multiprocessing`` or
``ipyparallel`` client with ELFI. The ``ipyparallel`` client supports
parallelization from local computer up to a cluster environment. For
local parallelization however, the ``multiprocessing`` client is simpler
to use. Let's begin by importing ELFI and our example MA2 model from the
to use. Lets begin by importing ELFI and our example MA2 model from the
tutorial.

.. code:: ipython3
import elfi
from elfi.examples import ma2
Let's get the model and plot it (requires graphviz)
Lets get the model and plot it (requires graphviz)

.. code:: ipython3
Expand All @@ -57,7 +57,7 @@ in your computer. You can activate it simply by
elfi.set_client('multiprocessing')
Any inference instance created **after** you have set the new client
will automatically use it to perform the computations. Let's try it with
will automatically use it to perform the computations. Lets try it with
our MA2 example model from the tutorial. When running the next command,
take a look at the system monitor of your operating system; it should
show that all of your cores are doing heavy computation simultaneously.
Expand Down Expand Up @@ -197,14 +197,14 @@ Working interactively with ipyparallel
--------------------------------------

If you are using the ``ipyparallel`` client from an interactive
environment (e.g. jupyter notebook) there are some things to take care
environment (e.g. jupyter notebook) there are some things to take care
of. All imports and definitions must be visible to all ``ipyparallel``
engines. You can ensure this by writing a script file that has all the
definitions in it. In a distributed setting, this file must be present
in all remote workers running an ``ipyparallel`` engine.

However, you may wish to experiment in an interactive session, using
e.g. a jupyter notebook. ``ipyparallel`` makes it possible to
e.g. a jupyter notebook. ``ipyparallel`` makes it possible to
interactively define functions for ELFI model and send them to workers.
This is especially useful if you work from a jupyter notebook. We will
show a few examples. More information can be found from ```ipyparallel``
Expand All @@ -220,7 +220,7 @@ functionality without problems:
rej2 = elfi.Rejection(d2, batch_size=10000)
result2 = rej2.sample(1000, quantile=0.01)
But let's say you want to use your very own distance function in a
But lets say you want to use your very own distance function in a
jupyter notebook:

.. code:: ipython3
Expand Down

0 comments on commit 269ac4f

Please sign in to comment.