Skip to content

Commit 5801738

Browse files
author
Jarno Lintusaari
authored
Merge pull request #213 from elfi-dev/dev
Version 0.6.1
2 parents f8d88c4 + 7baa409 commit 5801738

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1568
-830
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
#### Summary:
2+
Please provide a short summary here
23

3-
#### Intended Effect:
4-
5-
#### How to Verify:
6-
7-
#### Side Effects:
8-
9-
#### Successful inference in current Notebook examples:
10-
11-
#### Documentation:
12-
13-
#### Reviewer Suggestions:
4+
#### Please make sure
5+
- You have updated the CHANGELOG.rst
6+
- You have updated the documentation (if applicable)
147

158
#### Copyright and Licensing
169

CHANGELOG.rst

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

4+
0.6.1 (2017-07-21)
5+
------------------
6+
7+
- Fix elfi.Prior and NoneType error #203
8+
- Fix a bug preventing the reuse of ArrayPool data with a new inference
9+
- Added pickling for OutputPool:s
10+
- Added OutputPool.open to read a closed pool from disk
11+
- Refactored Sample and SmcSample classes
12+
- Added elfi.new_model method
13+
- Made elfi.set_client method to accept clients as strings for easier client switching
14+
- Fixed a bug in NpyArray that would lead to an inconsistent state if multiple
15+
simultaneous instances were opened.
16+
- Added the ability to move the pool data folder
17+
- Sample.summary is now a method instead of a property
18+
- SmcSample methods takes the keyword argument 'all' to show results of all populations
19+
- Added a section about iterative advancing to documentation
420

521
0.6 (2017-07-03)
622
----------------

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,23 @@ docs: ## generate Sphinx HTML documentation, including API docs
6969
$(MAKE) -C docs html
7070
# $(BROWSER) docs/_build/html/index.html
7171

72-
CONTENT_URL := http://research.cs.aalto.fi/pml/software/elfi/docs/0.6/
72+
CONTENT_URL := http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.1/
7373

7474
notebook-docs: ## Conver notebooks to rst docs. Assumes you have them in `notebooks` directory.
7575
jupyter nbconvert --to rst ../notebooks/quickstart.ipynb --output-dir docs
76-
sed -i '' 's|\(quickstart_files/quickstart.*\.\)|'${CONTENT_URL}'\1|g' docs/quickstart.rst
76+
sed -i 's|\(quickstart_files/quickstart.*\.\)|'${CONTENT_URL}'\1|g' docs/quickstart.rst
7777

7878
jupyter nbconvert --to rst ../notebooks/tutorial.ipynb --output-dir docs/usage
79-
sed -i '' 's|\(tutorial_files/tutorial.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/tutorial.rst
79+
sed -i 's|\(tutorial_files/tutorial.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/tutorial.rst
8080

8181
jupyter nbconvert --to rst ../notebooks/BOLFI.ipynb --output-dir docs/usage
82-
sed -i '' 's|\(BOLFI_files/BOLFI.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/BOLFI.rst
82+
sed -i 's|\(BOLFI_files/BOLFI.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/BOLFI.rst
8383

8484
jupyter nbconvert --to rst ../notebooks/parallelization.ipynb --output-dir docs/usage
85-
sed -i '' 's|\(parallelization_files/parallelization.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/parallelization.rst
85+
sed -i 's|\(parallelization_files/parallelization.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/parallelization.rst
8686

8787
jupyter nbconvert --to rst ../notebooks/non_python_operations.ipynb --output-dir docs/usage --output=external
88-
sed -i '' 's|\(external_files/external.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/external.rst
88+
sed -i 's|\(external_files/external.*\.\)|'${CONTENT_URL}usage/'\1|g' docs/usage/external.rst
8989

9090
# release: clean ## package and upload a release
9191
# python setup.py sdist upload

README.md

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

33
ELFI - Engine for Likelihood-Free Inference
44
===========================================
@@ -35,7 +35,7 @@ is preferable.
3535
Installation
3636
------------
3737

38-
ELFI requires and is tested with Python 3.5-3.6. You can install ELFI by typing in your terminal:
38+
ELFI requires Python 3.5 or greater. You can install ELFI by typing in your terminal:
3939

4040
```
4141
pip install elfi
@@ -78,5 +78,4 @@ Resolving these may sometimes go wrong:
7878
- If you receive an error about `yaml.load`, install `pyyaml`.
7979
- On OS X with Anaconda virtual environment say `conda install python.app` and then use
8080
`pythonw` instead of `python`.
81-
- Note that ELFI currently supports Python 3.5-3.6 only, although 3.x may work as well,
82-
so try `pip3 install elfi`.
81+
- Note that ELFI requires Python 3.5 or greater so try `pip3 install elfi`.

docs/api.rst

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Below is the API for creating generative models.
3131
.. currentmodule:: elfi.model.elfi_model
3232

3333
.. autosummary::
34+
elfi.new_model
3435
elfi.get_current_model
3536
elfi.set_current_model
3637

@@ -146,6 +147,8 @@ Modelling API classes
146147

147148
.. currentmodule:: elfi.model.elfi_model
148149

150+
.. automethod:: elfi.new_model
151+
149152
.. automethod:: elfi.get_current_model
150153

151154
.. automethod:: elfi.set_current_model

docs/developer/architecture.rst

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ e.g. the inference methods or the data storages. This information is aimed for d
77
and is not essential for using ELFI. We assume the reader is quite familiar with Python
88
and has perhaps already read some of ELFI's source code.
99

10-
The low level representation of the ELFI model is a ``networkx.DiGraph`` with nodes
11-
represented as Python dictionaries that are called node state dictionaries. This
12-
representation is held in ``ElfiModel.source_net``. Before the ELFI model can be ran, it
13-
needs to be compiled and loaded with data (e.g. observed data, precomputed data, batch
14-
index, batch size etc). The compilation and loading of data is the responsibility of the
15-
``Client`` implementation and makes it possible in essence to translate ``ElfiModel`` to
16-
any kind of computational backend. Finally the class ``Executor`` is responsible for
17-
running the compiled and loaded model and producing the outputs of the nodes.
10+
The low level representation of the ELFI model is a ``networkx.DiGraph`` with node names
11+
as the nodes. The representation of the node is stored to the corresponding attribute
12+
dictionary of the ``networkx.DiGraph``. We call this attribute dictionary the node *state*
13+
dictionary. The ``networkx.DiGraph`` representation can be found from
14+
``ElfiModel.source_net``. Before the ELFI model can be ran, it needs to be compiled and
15+
loaded with data (e.g. observed data, precomputed data, batch index, batch size etc). The
16+
compilation and loading of data is the responsibility of the ``Client`` implementation and
17+
makes it possible in essence to translate ``ElfiModel`` to any kind of computational
18+
backend. Finally the class ``Executor`` is responsible for running the compiled and loaded
19+
model and producing the outputs of the nodes.
1820

1921
A user typically creates this low level representation by working with subclasses of
2022
``NodeReference``. These are easy to use UI classes of ELFI such as the ``elfi.Simulator`` or

docs/installation.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ Or download the development `tarball`_:
7373
Note that for development it is recommended to base your work on the `dev` branch instead
7474
of `master`.
7575

76-
Once you have a copy of the source, you can install it with:
76+
Once you have a copy of the source, go to the folder and type:
7777

7878
.. code-block:: console
7979
8080
pip install -e .
8181
82-
This will install ELFI along with its default requirements.
82+
This will install ELFI along with its default requirements. Note that the dot in the end
83+
means the current folder.
8384

8485
.. _Github repo: https://github.com/elfi-dev/elfi
8586
.. _tarball: https://github.com/elfi-dev/elfi/tarball/dev

docs/quickstart.rst

+19-12
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ First ensure you have
77
Python 3.5 (or greater) and ELFI. After installation you can start using
88
ELFI:
99

10-
.. code:: ipython3
10+
.. code:: python
1111
1212
import elfi
1313
1414
ELFI includes an easy to use generative modeling syntax, where the
1515
generative model is specified as a directed acyclic graph (DAG). Let’s
1616
create two prior nodes:
1717

18-
.. code:: ipython3
18+
.. code:: python
1919
2020
mu = elfi.Prior('uniform', -2, 4)
2121
sigma = elfi.Prior('uniform', 1, 4)
@@ -30,7 +30,7 @@ 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
3131
standard deviation. Let's use mean and variance as our summaries:
3232

33-
.. code:: ipython3
33+
.. code:: python
3434
3535
import scipy.stats as ss
3636
import numpy as np
@@ -48,7 +48,7 @@ standard deviation. Let's use mean and variance as our summaries:
4848
Let’s now assume we have some observed data ``y0`` (here we just create
4949
some with the simulator):
5050

51-
.. code:: ipython3
51+
.. code:: python
5252
5353
# Set the generating parameters that we will try to infer
5454
mean0 = 1
@@ -73,7 +73,7 @@ Now we have all the components needed. Let’s complete our model by
7373
adding the simulator, the observed data, summaries and a distance to our
7474
model:
7575

76-
.. code:: ipython3
76+
.. code:: python
7777
7878
# Add the simulator node and observed data to the model
7979
sim = elfi.Simulator(simulator, mu, sigma, observed=y0)
@@ -85,23 +85,30 @@ model:
8585
# Specify distance as euclidean between summary vectors (S1, S2) from simulated and
8686
# observed data
8787
d = elfi.Distance('euclidean', S1, S2)
88-
88+
89+
If you have ``graphviz`` installed to your system, you can also
90+
visualize the model:
91+
92+
.. code:: python
93+
8994
# Plot the complete model (requires graphviz)
9095
elfi.draw(d)
9196
9297
9398
9499
95-
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6/quickstart_files/quickstart_9_0.svg
100+
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.1/quickstart_files/quickstart_11_0.svg
101+
96102

97103

104+
.. Note:: The automatic naming of nodes may not work in all environments e.g. in interactive Python shells. You can alternatively provide a name argument for the nodes, e.g. ``S1 = elfi.Summary(mean, sim, name='S1')``.
98105

99106
We can try to infer the true generating parameters ``mean0`` and
100107
``std0`` above with any of ELFI’s inference methods. Let’s use ABC
101108
Rejection sampling and sample 1000 samples from the approximate
102109
posterior using threshold value 0.5:
103110

104-
.. code:: ipython3
111+
.. code:: python
105112
106113
rej = elfi.Rejection(d, batch_size=10000, seed=30052017)
107114
res = rej.sample(1000, threshold=.5)
@@ -111,22 +118,22 @@ posterior using threshold value 0.5:
111118
.. parsed-literal::
112119
113120
Method: Rejection
114-
Number of posterior samples: 1000
121+
Number of samples: 1000
115122
Number of simulations: 120000
116123
Threshold: 0.492
117-
Posterior means: mu: 0.748, sigma: 3.1
124+
Sample means: mu: 0.748, sigma: 3.1
118125
119126
120127
121128
Let's plot also the marginal distributions for the parameters:
122129

123-
.. code:: ipython3
130+
.. code:: python
124131
125132
import matplotlib.pyplot as plt
126133
res.plot_marginals()
127134
plt.show()
128135
129136
130137
131-
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6/quickstart_files/quickstart_13_0.png
138+
.. image:: http://research.cs.aalto.fi/pml/software/elfi/docs/0.6.1/quickstart_files/quickstart_16_0.png
132139

0 commit comments

Comments
 (0)