Skip to content

Commit bc7df0c

Browse files
committed
Merge branch 'master' into compare_tweak
2 parents 3dd693d + 999661c commit bc7df0c

File tree

126 files changed

+8396
-4403
lines changed

Some content is hidden

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

126 files changed

+8396
-4403
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ mcmc.sqlite
2929
benchmarks/env/
3030
benchmarks/html/
3131
benchmarks/results/
32+
.pytest_cache/

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: python
2-
sudo: false
2+
sudo: required
33

44
cache:
55
directories:
66
- $HOME/.theano
7-
- $HOME/minicoda2
8-
- $HOME/minicoda3
7+
- $HOME/miniconda2
8+
- $HOME/miniconda3
99

1010
addons:
1111
apt_packages:
@@ -15,12 +15,11 @@ before_install:
1515
- . ./scripts/install_miniconda.sh
1616
- sh -e /etc/init.d/xvfb start
1717
- export DISPLAY=":99.0"
18+
- export MKL_THREADING_LAYER=GNU
1819

1920
install:
2021
- . ./scripts/create_testenv.sh
21-
- pip install coveralls pylint
22-
- pip install travis-sphinx==2.0.0
23-
- pip install -r requirements-dev.txt
22+
- pip install coveralls travis-sphinx==2.0.0
2423

2524
env:
2625
- PYTHON_VERSION=2.7 FLOATX='float32' TESTCMD="--durations=10 --ignore=pymc3/tests/test_examples.py --cov-append --ignore=pymc3/tests/test_distributions_random.py --ignore=pymc3/tests/test_variational_inference.py --ignore=pymc3/tests/test_shared.py --ignore=pymc3/tests/test_smc.py --ignore=pymc3/tests/test_updates.py --ignore=pymc3/tests/test_posteriors.py --ignore=pymc3/tests/test_sampling.py"

README.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ which focuses on advanced Markov chain Monte Carlo and variational fitting
1010
algorithms. Its flexibility and extensibility make it applicable to a
1111
large suite of problems.
1212

13-
Check out the `getting started guide <http://docs.pymc.io/notebooks/getting_started>`__, or
13+
Check out the `getting started guide <http://docs.pymc.io/notebooks/getting_started>`__, or
1414
`interact with live examples <https://mybinder.org/v2/gh/pymc-devs/pymc3/master?filepath=%2Fdocs%2Fsource%2Fnotebooks>`__
1515
using Binder!
1616

@@ -114,8 +114,6 @@ Optional
114114
In addtion to the above dependencies, the GLM submodule relies on
115115
`Patsy <http://patsy.readthedocs.io/en/latest/>`__.
116116

117-
`scikits.sparse <https://github.com/njsmith/scikits-sparse>`__
118-
enables sparse scaling matrices which are useful for large problems.
119117

120118
Citing PyMC3
121119
============
@@ -127,7 +125,7 @@ in Python using PyMC3. PeerJ Computer Science 2:e55
127125
Contact
128126
=======
129127

130-
We are using `discourse.pymc.io <https://discourse.pymc.io/>`__ as our main communication channel. You can also follow us on `Twitter @pymc_devs <https://twitter.com/pymc_devs>`__ for updates and other announcements.
128+
We are using `discourse.pymc.io <https://discourse.pymc.io/>`__ as our main communication channel. You can also follow us on `Twitter @pymc_devs <https://twitter.com/pymc_devs>`__ for updates and other announcements.
131129

132130
To ask a question regarding modeling or usage of PyMC3 we encourage posting to our Discourse forum under the `“Questions” Category <https://discourse.pymc.io/c/questions>`__. You can also suggest feature in the `“Development” Category <https://discourse.pymc.io/c/development>`__.
133131

@@ -145,11 +143,12 @@ License
145143
Software using PyMC3
146144
====================
147145

148-
- `sampled <https://github.com/ColCarroll/sampled>`__: Decorator for PyMC3.
149-
- `Bambi <https://github.com/bambinos/bambi>`__: BAyesian Model-Building Interface (BAMBI) in Python.
150-
- `gelato <https://github.com/ferrine/gelato>`__: Bayesian Neural Networks with PyMC3 and Lasagne.
151-
- `NiPyMC <https://github.com/PsychoinformaticsLab/nipymc>`__: Bayesian mixed-effects modeling of fMRI data in Python.
152-
- `beat <https://github.com/hvasbath/beat>`__: Bayesian Earthquake Analysis Tool.
146+
- `Bambi <https://github.com/bambinos/bambi>`__: BAyesian Model-Building Interface (BAMBI) in Python.
147+
- `pymc3_models <https://github.com/parsing-science/pymc3_models>`__: Custom PyMC3 models built on top of the scikit-learn API.
148+
- `webmc3 <https://github.com/AustinRochford/webmc3>`__: A web interface for exploring PyMC3 traces
149+
- `sampled <https://github.com/ColCarroll/sampled>`__: Decorator for PyMC3 models.
150+
- `NiPyMC <https://github.com/PsychoinformaticsLab/nipymc>`__: Bayesian mixed-effects modeling of fMRI data in Python.
151+
- `beat <https://github.com/hvasbath/beat>`__: Bayesian Earthquake Analysis Tool.
153152

154153

155154
Please contact us if your software is not listed here.
@@ -177,7 +176,7 @@ Sponsors
177176

178177
|Quantopian|
179178

180-
.. |Binder| image:: https://mybinder.org/badge.svg
179+
.. |Binder| image:: https://mybinder.org/badge.svg
181180
:target: https://mybinder.org/v2/gh/pymc-devs/pymc3/master?filepath=%2Fdocs%2Fsource%2Fnotebooks
182181
.. |Build Status| image:: https://travis-ci.org/pymc-devs/pymc3.png?branch=master
183182
:target: https://travis-ci.org/pymc-devs/pymc3

RELEASE-NOTES.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
# Release Notes
22

3-
## PyMC 3.3. (Unreleased)
3+
## PyMC 3.4 (unreleased)
4+
5+
### New features
6+
7+
- Add `logit_p` keyword to `pm.Bernoulli`, so that users can specify the logit of the success probability. This is faster and more stable than using `p=tt.nnet.sigmoid(logit_p)`.
8+
- Add `random` keyword to `pm.DensityDist` thus enabling users to pass custom random method which in turn makes sampling from a `DensityDist` possible.
9+
- Effective sample size computation is updated. The estimation uses Geyer's initial positive sequence, which no longer truncates the autocorrelation series inaccurately. `pm.diagnostics.effective_n` now can reports N_eff>N.
10+
- Added `KroneckerNormal` distribution and a corresponding `MarginalKron`
11+
Gaussian Process implementation for efficient inference, along with
12+
lower-level functions such as `cartesian` and `kronecker` products.
13+
- Added `Coregion` covariance function.
14+
- Add new 'pairplot' function, for plotting scatter or hexbin matrices of sampled parameters.
15+
Optionally it can plot divergences.
16+
- Plots of discrete distributions in the docstrings
17+
- Add logitnormal distribution
18+
- Densityplot: add support for discrete variables
19+
- Fix the Binomial likelihood in `.glm.families.Binomial`, with the flexibility of specifying the `n`.
20+
- Add `offset` kwarg to `.glm`.
21+
22+
### Fixes
23+
24+
- `VonMises` does not overflow for large values of kappa. i0 and i1 have been removed and we now use log_i0 to compute the logp.
25+
- The bandwidth for KDE plots is computed using a modified version of Scott's rule. The new version uses entropy instead of standard deviation. This works better for multimodal distributions. Functions using KDE plots has a new argument `bw` controlling the bandwidth.
26+
- fix PyMC3 variable is not replaced if provided in more_replacements (#2890)
27+
28+
### Deprecations
29+
30+
- DIC and BPIC calculations have been removed
31+
- df_summary have been removed, use summary instead
32+
- `njobs` and `nchains` kwarg are deprecated in favor of `cores` and `chains` for `sample`
33+
- `lag` kwarg in `pm.stats.autocorr` and `pm.stats.autocov` is deprecated.
34+
35+
36+
## PyMC 3.3 (January 9, 2018)
437

538
### New features
639

@@ -10,13 +43,12 @@
1043
- New benchmark suite added (see http://pandas.pydata.org/speed/pymc3/)
1144
- Generalized random seed types
1245
- Update loo, new improved algorithm (#2730)
13-
- New CSG (Constant Stochastic Gradient) approximate posterior sampling
14-
algorithm (#2544)
46+
- New CSG (Constant Stochastic Gradient) approximate posterior sampling algorithm (#2544)
1547
- Michael Osthege added support for population-samplers and implemented differential evolution metropolis (`DEMetropolis`). For models with correlated dimensions that can not use gradient-based samplers, the `DEMetropolis` sampler can give higher effective sampling rates. (also see [PR#2735](https://github.com/pymc-devs/pymc3/pull/2735))
1648
- Forestplot supports multiple traces (#2736)
1749
- Add new plot, densityplot (#2741)
1850
- DIC and BPIC calculations have been deprecated
19-
- `compare` now accepts dictionary of model:trace pairs instead of lists
51+
- Refactor HMC and implemented new warning system (#2677, #2808)
2052

2153
### Fixes
2254

@@ -28,6 +60,12 @@
2860
- Fixed `sample_ppc` and `sample_ppc_w` to iterate all chains(#2633, #2748)
2961
- Add Bayesian R2 score (for GLMs) `stats.r2_score` (#2696) and test (#2729).
3062
- SMC works with transformed variables (#2755)
63+
- Speedup OPVI (#2759)
64+
- Multiple minor fixes and improvements in the docs (#2775, #2786, #2787, #2789, #2790, #2794, #2799, #2809)
65+
66+
### Deprecations
67+
68+
- Old (`minibatch-`)`advi` is removed (#2781)
3169

3270

3371
## PyMC3 3.2 (October 10, 2017)

benchmarks/benchmarks/benchmarks.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def setup(self, step):
7171

7272
def time_overhead_sample(self, step):
7373
with self.model:
74-
pm.sample(self.n_steps, step=step(), random_seed=1)
74+
pm.sample(self.n_steps, step=step(), random_seed=1,
75+
progressbar=False, compute_convergence_checks=False)
7576

7677

7778
class ExampleSuite(object):
@@ -115,11 +116,13 @@ def time_drug_evaluation(self):
115116
pm.Deterministic('difference of stds', group1_std - group2_std)
116117
pm.Deterministic(
117118
'effect size', diff_of_means / np.sqrt((group1_std**2 + group2_std**2) / 2))
118-
pm.sample(20000, njobs=4, chains=4)
119+
pm.sample(draws=20000, cores=4, chains=4,
120+
progressbar=False, compute_convergence_checks=False)
119121

120122
def time_glm_hierarchical(self):
121123
with glm_hierarchical_model():
122-
pm.sample(draws=20000, njobs=4, chains=4)
124+
pm.sample(draws=20000, cores=4, chains=4,
125+
progressbar=False, compute_convergence_checks=False)
123126

124127

125128
class NUTSInitSuite(object):
@@ -141,8 +144,9 @@ def track_glm_hierarchical_ess(self, init):
141144
with glm_hierarchical_model():
142145
start, step = pm.init_nuts(init=init, chains=self.chains, progressbar=False, random_seed=123)
143146
t0 = time.time()
144-
trace = pm.sample(draws=self.draws, step=step, njobs=4, chains=self.chains,
145-
start=start, random_seed=100)
147+
trace = pm.sample(draws=self.draws, step=step, cores=4, chains=self.chains,
148+
start=start, random_seed=100, progressbar=False,
149+
compute_convergence_checks=False)
146150
tot = time.time() - t0
147151
ess = pm.effective_n(trace, ('mu_a',))['mu_a']
148152
return ess / tot
@@ -154,8 +158,9 @@ def track_marginal_mixture_model_ess(self, init):
154158
progressbar=False, random_seed=123)
155159
start = [{k: v for k, v in start.items()} for _ in range(self.chains)]
156160
t0 = time.time()
157-
trace = pm.sample(draws=self.draws, step=step, njobs=4, chains=self.chains,
158-
start=start, random_seed=100)
161+
trace = pm.sample(draws=self.draws, step=step, cores=4, chains=self.chains,
162+
start=start, random_seed=100, progressbar=False,
163+
compute_convergence_checks=False)
159164
tot = time.time() - t0
160165
ess = pm.effective_n(trace, ('mu',))['mu'].min() # worst case
161166
return ess / tot
@@ -178,8 +183,9 @@ def track_glm_hierarchical_ess(self, step):
178183
if step is not None:
179184
step = step()
180185
t0 = time.time()
181-
trace = pm.sample(draws=self.draws, step=step, njobs=4, chains=4,
182-
random_seed=100)
186+
trace = pm.sample(draws=self.draws, step=step, cores=4, chains=4,
187+
random_seed=100, progressbar=False,
188+
compute_convergence_checks=False)
183189
tot = time.time() - t0
184190
ess = pm.effective_n(trace, ('mu_a',))['mu_a']
185191
return ess / tot

docs/source/_static/.gitignore

Whitespace-only changes.

docs/source/advanced_theano.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Using shared variables
77

88
Shared variables allow us to use values in theano functions that are
99
not considered an input to the function, but can still be changed
10-
later. They are very similar to global variables in may ways.::
10+
later. They are very similar to global variables in may ways::
1111

1212
a = tt.scalar('a')
1313
# Create a new shared variable with initial value of 0.1
@@ -23,7 +23,7 @@ their shape as long as the number of dimensions stays the same.
2323

2424
We can use shared variables in PyMC3 to fit the same model to several
2525
datasets without the need to recreate the model each time (which can
26-
be time consuming if the number of datasets is large).::
26+
be time consuming if the number of datasets is large)::
2727

2828
# We generate 10 datasets
2929
true_mu = [np.random.randn() for _ in range(10)]

docs/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ API Reference
1818
api/backends
1919
api/math
2020
api/data
21+
api/model

docs/source/api/bounds.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22
Bounded Variables
33
=================
44

5-
PyMC3 includes the construct ``Bound`` for placing constraints on existing
6-
probability distributions. It modifies a given distribution to take values
7-
only within a specified interval.
5+
PyMC3 includes the construct :class:`~pymc3.distributions.bound.Bound` for
6+
placing constraints on existing probability distributions. It modifies a given
7+
distribution to take values only within a specified interval.
88

99
Some types of variables require constraints. For instance, it doesn't make
1010
sense for a standard deviation to have a negative value, so something like a
1111
Normal prior on a parameter that represents a standard deviation would be
1212
inappropriate. PyMC3 includes distributions that have positive support, such
13-
as ``Gamma`` or ``Exponential``. PyMC3 also includes several bounded
14-
distributions, such as ``Uniform``, ``HalfNormal``, and ``HalfCauchy``, that
15-
are restricted to a specific domain.
13+
as :class:`~pymc3.distributions.continuous.Gamma` or
14+
:class:`~pymc3.distributions.continuous.Exponential`. PyMC3 also includes
15+
several bounded distributions, such as
16+
:class:`~pymc3.distributions.continuous.Uniform`,
17+
:class:`~pymc3.distributions.continuous.HalfNormal`, and
18+
:class:`~pymc3.distributions.continuous.HalfCauchy`, that are restricted to a
19+
specific domain.
1620

1721
All univariate distributions in PyMC3 can be given bounds. The distribution of
1822
a continuous variable that has been bounded is automatically transformed into
@@ -32,7 +36,7 @@ specification of a bounded distribution should go within the model block::
3236
with pm.Model() as model:
3337
BoundedNormal = pm.Bound(pm.Normal, lower=0.0)
3438
x = BoundedNormal('x', mu=1.0, sd=3.0)
35-
39+
3640
If the bound will be applied to a single variable in the model, it may be
3741
cleaner notationally to define both the bound and variable together. ::
3842

@@ -42,17 +46,24 @@ cleaner notationally to define both the bound and variable together. ::
4246
Bounds can also be applied to a vector of random variables. With the same
4347
``BoundedNormal`` object we created previously we can write::
4448

45-
with model:
49+
with model:
4650
x_vector = BoundedNormal('x_vector', mu=1.0, sd=3.0, shape=3)
4751

4852
Caveats
4953
#######
5054

5155
* Bounds cannot be given to variables that are ``observed``. To model
52-
truncated data, use a ``Potential`` in combination with a cumulative
56+
truncated data, use a :func:`~pymc3.model.Potential` in combination with a cumulative
5357
probability function. See `this example <https://github.com/pymc-devs/pymc3/blob/master/pymc3/examples/censored_data.py>`_.
5458

5559
* The automatic transformation applied to continuous distributions results in
5660
an unnormalized probability distribution. This doesn't effect inference
5761
algorithms but may complicate some model comparison procedures.
5862

63+
API
64+
###
65+
66+
67+
.. currentmodule:: pymc3.distributions.bound
68+
.. automodule:: pymc3.distributions.bound
69+
:members:

docs/source/api/distributions/continuous.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Continuous
2929
VonMises
3030
Triangular
3131
Gumbel
32+
Logistic
33+
LogitNormal
3234
Interpolated
3335

3436
.. automodule:: pymc3.distributions.continuous

0 commit comments

Comments
 (0)