Skip to content

Fix warnings from docstrings when building docs, remove t_stick_breaking #4283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions docs/source/api/distributions/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ implemented as ``pm.distributions.transforms.``\*X*.
ordered
log
sum_to_1
t_stick_breaking
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in #4129 , looks like it was never removed from here though

circular
CholeskyCovPacked
Chain
Expand Down Expand Up @@ -93,10 +92,6 @@ below.
:class:`~pymc3.distributions.transforms.Circular` :class:`~pymc3.distributions.transforms.Transform` class
for use in the ``transform`` argument of a random variable.


.. autofunction:: t_stick_breaking


Transform Base Classes
~~~~~~~~~~~~~~~~~~~~~~

Expand Down
1 change: 1 addition & 0 deletions docs/source/api/plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Plots
*****

.. currentmodule:: pymc3.plots

Plots are delegated to the
`ArviZ <https://arviz-devs.github.io/arviz/index.html>`_.
library, a general purpose library for
Expand Down
16 changes: 8 additions & 8 deletions pymc3/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ class MultiTrace:

Attributes
----------
nchains: int
Number of chains in the `MultiTrace`.
chains: `List[int]`
List of chain indices
report: str
Report on the sampling process.
varnames: `List[str]`
List of variable names in the trace(s)
nchains: int
Number of chains in the `MultiTrace`.
chains: `List[int]`
List of chain indices
report: str
Report on the sampling process.
varnames: `List[str]`
List of variable names in the trace(s)
"""

def __init__(self, straces):
Expand Down
3 changes: 2 additions & 1 deletion pymc3/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ def jacobian_det(self, x):
class StickBreaking(Transform):
"""
Transforms K - 1 dimensional simplex space (k values in [0,1] and that sum to 1) to a K - 1 vector of real values.
This is a variant of the isometric logration transformation:
This is a variant of the isometric logration transformation ::

Egozcue, J.J., Pawlowsky-Glahn, V., Mateu-Figueras, G. et al.
Isometric Logratio Transformations for Compositional Data Analysis.
Mathematical Geology 35, 279–300 (2003). https://doi.org/10.1023/A:1023818214614
Expand Down
76 changes: 39 additions & 37 deletions pymc3/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def sample(
pickle_backend: str = "pickle",
**kwargs,
):
"""Draw samples from the posterior using the given step methods.
r"""Draw samples from the posterior using the given step methods.

Multiple step methods are supported via compound step methods.

Expand Down Expand Up @@ -330,7 +330,6 @@ def sample(
called with the trace and the current draw and will contain all samples for a single trace.
the ``draw.chain`` argument can be used to determine which of the active chains the sample
is drawn from.

Sampling can be interrupted by throwing a ``KeyboardInterrupt`` in the callback.
return_inferencedata : bool, default=False
Whether to return the trace as an :class:`arviz:arviz.InferenceData` (True) object or a `MultiTrace` (False)
Expand All @@ -353,7 +352,7 @@ def sample(
Notes
-----
Optional keyword arguments can be passed to ``sample`` to be delivered to the
``step_method``s used during sampling.
``step_method``\ s used during sampling.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On master:

image

This branch:

image


If your model uses only one step method, you can address step method kwargs
directly. In particular, the NUTS step method has several options including:
Expand All @@ -368,49 +367,52 @@ def sample(
If your model uses multiple step methods, aka a Compound Step, then you have
two ways to address arguments to each step method:

A: If you let ``sample()`` automatically assign the ``step_method``s,
and you can correctly anticipate what they will be, then you can wrap
step method kwargs in a dict and pass that to sample() with a kwarg set
to the name of the step method.
e.g. for a CompoundStep comprising NUTS and BinaryGibbsMetropolis,
you could send:
1. ``target_accept`` to NUTS: nuts={'target_accept':0.9}
2. ``transit_p`` to BinaryGibbsMetropolis: binary_gibbs_metropolis={'transit_p':.7}

Note that available names are:
``nuts``, ``hmc``, ``metropolis``, ``binary_metropolis``,
``binary_gibbs_metropolis``, ``categorical_gibbs_metropolis``,
``DEMetropolis``, ``DEMetropolisZ``, ``slice``

B: If you manually declare the ``step_method``s, within the ``step``
kwarg, then you can address the ``step_method`` kwargs directly.
e.g. for a CompoundStep comprising NUTS and BinaryGibbsMetropolis,
you could send:
step=[pm.NUTS([freeRV1, freeRV2], target_accept=0.9),
pm.BinaryGibbsMetropolis([freeRV3], transit_p=.7)]
A. If you let ``sample()`` automatically assign the ``step_method``\ s,
and you can correctly anticipate what they will be, then you can wrap
step method kwargs in a dict and pass that to sample() with a kwarg set
to the name of the step method.
e.g. for a CompoundStep comprising NUTS and BinaryGibbsMetropolis,
you could send:

1. ``target_accept`` to NUTS: nuts={'target_accept':0.9}
2. ``transit_p`` to BinaryGibbsMetropolis: binary_gibbs_metropolis={'transit_p':.7}

Note that available names are:

``nuts``, ``hmc``, ``metropolis``, ``binary_metropolis``,
``binary_gibbs_metropolis``, ``categorical_gibbs_metropolis``,
``DEMetropolis``, ``DEMetropolisZ``, ``slice``

B. If you manually declare the ``step_method``\ s, within the ``step``
kwarg, then you can address the ``step_method`` kwargs directly.
e.g. for a CompoundStep comprising NUTS and BinaryGibbsMetropolis,
you could send ::

step=[pm.NUTS([freeRV1, freeRV2], target_accept=0.9),
pm.BinaryGibbsMetropolis([freeRV3], transit_p=.7)]

You can find a full list of arguments in the docstring of the step methods.

Examples
--------
.. code:: ipython

>>> import pymc3 as pm
... n = 100
... h = 61
... alpha = 2
... beta = 2
In [1]: import pymc3 as pm
...: n = 100
...: h = 61
...: alpha = 2
...: beta = 2

.. code:: ipython
In [2]: with pm.Model() as model: # context management
...: p = pm.Beta("p", alpha=alpha, beta=beta)
...: y = pm.Binomial("y", n=n, p=p, observed=h)
...: trace = pm.sample()

>>> with pm.Model() as model: # context management
... p = pm.Beta('p', alpha=alpha, beta=beta)
... y = pm.Binomial('y', n=n, p=p, observed=h)
... trace = pm.sample()
>>> pm.summary(trace)
mean sd mc_error hpd_2.5 hpd_97.5
p 0.604625 0.047086 0.00078 0.510498 0.694774
In [3]: pm.summary(trace, kind="stats")

Out[3]:
mean sd hdi_3% hdi_97%
p 0.609 0.047 0.528 0.699
Comment on lines -398 to +415
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

"""
model = modelcontext(model)
if start is None:
Expand Down Expand Up @@ -1982,7 +1984,7 @@ def init_nuts(
* map: Use the MAP as starting point. This is discouraged.
* adapt_full: Adapt a dense mass matrix using the sample covariances. All chains use the
test value (usually the prior mean) as starting point.
* jitter+adapt_full: Same as ``adapt_full`, but use test value plus a uniform jitter in
* jitter+adapt_full: Same as ``adapt_full``, but use test value plus a uniform jitter in
[-1, 1] as starting point in each chain.

chains : int
Expand Down