Skip to content

Commit ff25fcb

Browse files
authored
Merge pull request #290 from elfi-dev/dev
Release v. 0.7.3
2 parents ce02414 + 269ac4f commit ff25fcb

28 files changed

+560
-167
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,6 @@ ENV
104104
*.swo
105105
*.swp
106106

107+
# Compiled stuff
108+
bdm
109+
elfi/examples/cpp/bdm

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ matrix:
1111
before_install:
1212
- mkdir -p /Users/travis/.matplotlib
1313
- "echo 'backend: TkAgg' > /Users/travis/.matplotlib/matplotlibrc"
14-
- brew update
15-
- brew upgrade python
16-
- pip3 install virtualenv
17-
- virtualenv py3env -p python3
18-
- source py3env/bin/activate
14+
- travis_retry wget "http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" -O miniconda.sh
15+
- "bash miniconda.sh -b -p $HOME/miniconda"
16+
- "export PATH=$HOME/miniconda/bin:$PATH"
17+
- "conda create -y -n elfi python=3.6 scipy"
18+
- "source activate elfi"
1919

2020
cache: pip
2121

CHANGELOG.rst

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
=========
33

4+
0.7.3 (2018-08-30)
5+
------------------
6+
- Fix bug in plot_pairs which crashes in case of 1 parameter
7+
- Fix bug in plot_marginals which outputs empty plots in case where we have parameter more than 5
8+
- Fix crashing summary and plots for samples with multivariate priors
9+
- Add progress bar for inference methods
10+
- Add method save to Sample objects
11+
- Add support for giving seed to `generate`
12+
- Implement elfi.plot_params_vs_node for plotting parameters vs. node output
13+
414
0.7.2 (2018-06-20)
515
------------------
616
- Added support for kwargs in elfi.set_client

Dockerfile

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
FROM python:3.6
1+
FROM ubuntu:bionic
22

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

56
WORKDIR /elfi
67
ADD . /elfi
78

8-
RUN pip install numpy graphviz
9-
RUN pip install -e .
10-
RUN pip install -r requirements-dev.txt
11-
12-
# matplotlib unable to show figures
13-
RUN mkdir -p /root/.config/matplotlib
14-
RUN echo "backend : Agg" >> /root/.config/matplotlib/matplotlibrc
15-
16-
CMD ["/bin/bash"]
9+
RUN pip3 install -e .
10+
RUN pip3 install -r requirements-dev.txt

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**Version 0.7.2 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
1+
**Version 0.7.3 released!** See the CHANGELOG and [notebooks](https://github.com/elfi-dev/notebooks).
22

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

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

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

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

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

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

3939

@@ -48,9 +48,9 @@ pip install elfi
4848
or on some platforms using Python 3 specific syntax:
4949
```
5050
pip3 install elfi
51-
```
51+
```
5252

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

5656
### Optional dependencies
@@ -77,7 +77,7 @@ pip install elfi
7777

7878
### Docker container
7979

80-
A simple Dockerfile for command-line interface is also provided. Please see [Docker documentation](https://docs.docker.com/).
80+
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.
8181

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

8989
### Potential problems with installation
9090

91-
ELFI depends on several other Python packages, which have their own dependencies.
91+
ELFI depends on several other Python packages, which have their own dependencies.
9292
Resolving these may sometimes go wrong:
9393
- If you receive an error about missing `numpy`, please install it first.
9494
- If you receive an error about `yaml.load`, install `pyyaml`.
95-
- On OS X with Anaconda virtual environment say `conda install python.app` and then use
95+
- On OS X with Anaconda virtual environment say `conda install python.app` and then use
9696
`pythonw` instead of `python`.
9797
- Note that ELFI requires Python 3.5 or greater so try `pip3 install elfi`.
9898
- Make sure your Python installation meets the versions listed in `requirements.txt`.

docs/api.rst

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Below is the API for creating generative models.
3838

3939
.. autosummary::
4040
elfi.draw
41+
elfi.plot_params_vs_node
4142

4243
Inference API
4344
-------------
@@ -177,6 +178,8 @@ Modelling API classes
177178

178179
.. autofunction:: elfi.draw
179180

181+
.. autofunction:: elfi.plot_params_vs_node
182+
180183
.. This would show undocumented members :undoc-members:
181184
182185

docs/installation.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ means the current folder.
9292
Docker container
9393
----------------
9494

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

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

docs/quickstart.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ for the standard deviation ``sigma``. All distributions from
2828
For likelihood-free models we typically need to define a simulator and
2929
summary statistics for the data. As an example, lets define the
3030
simulator as 30 draws from a Gaussian distribution with a given mean and
31-
standard deviation. Let's use mean and variance as our summaries:
31+
standard deviation. Lets use mean and variance as our summaries:
3232

3333
.. code:: ipython3
3434
@@ -125,7 +125,7 @@ posterior using threshold value 0.5:
125125
126126
127127
128-
Let's plot also the marginal distributions for the parameters:
128+
Lets plot also the marginal distributions for the parameters:
129129

130130
.. code:: ipython3
131131

docs/usage/BOLFI.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ initialize the GP model with a dictionary of previous results by giving
101101

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

107107
.. code:: ipython3
@@ -263,7 +263,7 @@ is a sophisticated algorithm, and in some cases one may get warnings
263263
about diverged proposals, which are signs that `something may be wrong
264264
and should be
265265
investigated <http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup>`__.
266-
It is good to understand the cause of these warnings although they don't
266+
It is good to understand the cause of these warnings although they dont
267267
automatically mean that the results are unreliable. You could try
268268
rerunning the ``sample`` method with a higher target probability
269269
``target_prob`` during adaptation, as its default 0.6 may be inadequate

docs/usage/external.rst

+23-23
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ If your simulator or other operations are implemented in a programming
1010
language other than Python, you can still use ELFI. This notebook
1111
briefly demonstrates how to do this in three common scenarios:
1212

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

17-
Let's begin by importing some libraries that we will be using:
17+
Lets begin by importing some libraries that we will be using:
1818

1919
.. code:: ipython3
2020
@@ -43,7 +43,7 @@ introduced in this tutorial.
4343

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

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

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

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

109109
Birth-Death-Mutation process
110110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111111

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

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

134134
.. For documentation
135135
@@ -140,8 +140,8 @@ original paper or e.g. `*Lintusaari at al
140140

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

147147
.. code:: ipython3
@@ -154,7 +154,7 @@ start by defining some constants:
154154
# The zeros are to make the observed population vector have length N
155155
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')
156156
157-
Let's build the beginning of a new model for the birth rate
157+
Lets build the beginning of a new model for the birth rate
158158
:math:`\alpha` as the only unknown
159159

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

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

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

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

313313
.. code:: ipython3
314314
@@ -421,7 +421,7 @@ the functionality of R from within Python. You can install it with
421421
``pip install rpy2``.
422422

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

427427
.. code:: ipython3
@@ -436,7 +436,7 @@ model.
436436

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

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

442442
.. code:: ipython3
@@ -600,7 +600,7 @@ Replace the summaries S1 and S2 with our R autocovariance function.
600600
601601
602602
603-
Finally, don't forget to quit the MATLAB session:
603+
Finally, dont forget to quit the MATLAB session:
604604

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

0 commit comments

Comments
 (0)