Skip to content

Commit e6489e4

Browse files
authored
Merge pull request #707 from stan-dev/docs/701-pathfinder
Docs/701 pathfinder
2 parents d4839e0 + 3ba5f11 commit e6489e4

22 files changed

+834
-428
lines changed

cmdstanpy/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,8 +1882,8 @@ def laplace_sample(
18821882
either as a dictionary with entries matching the data variables,
18831883
or as the path of a data file in JSON or Rdump format.
18841884
1885-
:param mode: The mode around which to place the approximation.
1886-
This can be:
1885+
:param mode: The mode around which to place the approximation, either
1886+
18871887
* A :class:`CmdStanMLE` object
18881888
* A path to a CSV file containing the output of an optimization run.
18891889
* ``None`` - use default optimizer settings and/or any ``opt_args``.

cmdstanpy/stanfit/gq.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,9 @@ def stan_variable(
566566
CmdStanGQ.stan_variables
567567
CmdStanMCMC.stan_variable
568568
CmdStanMLE.stan_variable
569+
CmdStanPathfinder.stan_variable
569570
CmdStanVB.stan_variable
571+
CmdStanLaplace.stan_variable
570572
"""
571573
model_var_names = self.previous_fit._metadata.stan_vars.keys()
572574
gq_var_names = self._metadata.stan_vars.keys()
@@ -613,7 +615,9 @@ def stan_variables(self, inc_warmup: bool = False) -> Dict[str, np.ndarray]:
613615
CmdStanGQ.stan_variable
614616
CmdStanMCMC.stan_variables
615617
CmdStanMLE.stan_variables
618+
CmdStanPathfinder.stan_variables
616619
CmdStanVB.stan_variables
620+
CmdStanLaplace.stan_variables
617621
"""
618622
result = {}
619623
sample_var_names = self.previous_fit._metadata.stan_vars.keys()

cmdstanpy/stanfit/laplace.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def stan_variable(self, var: str) -> np.ndarray:
8282
--------
8383
CmdStanMLE.stan_variables
8484
CmdStanMCMC.stan_variable
85+
CmdStanPathfinder.stan_variable
8586
CmdStanVB.stan_variable
8687
CmdStanGQ.stan_variable
8788
"""
@@ -113,6 +114,7 @@ def stan_variables(self) -> Dict[str, np.ndarray]:
113114
CmdStanGQ.stan_variable
114115
CmdStanMCMC.stan_variables
115116
CmdStanMLE.stan_variables
117+
CmdStanPathfinder.stan_variables
116118
CmdStanVB.stan_variables
117119
"""
118120
result = {}
@@ -235,7 +237,9 @@ def mode(self) -> CmdStanMLE:
235237
@property
236238
def metadata(self) -> InferenceMetadata:
237239
"""
238-
Return the inference metadata as an :class:`InferenceMetadata` object.
240+
Returns object which contains CmdStan configuration as well as
241+
information about the names and structure of the inference method
242+
and model output variables.
239243
"""
240244
return self._metadata
241245

cmdstanpy/stanfit/mcmc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,10 @@ def stan_variable(
748748
--------
749749
CmdStanMCMC.stan_variables
750750
CmdStanMLE.stan_variable
751+
CmdStanPathfinder.stan_variable
751752
CmdStanVB.stan_variable
752753
CmdStanGQ.stan_variable
754+
CmdStanLaplace.stan_variable
753755
"""
754756
try:
755757
draws = self.draws(inc_warmup=inc_warmup, concat_chains=True)
@@ -774,8 +776,10 @@ def stan_variables(self) -> Dict[str, np.ndarray]:
774776
--------
775777
CmdStanMCMC.stan_variable
776778
CmdStanMLE.stan_variables
779+
CmdStanPathfinder.stan_variables
777780
CmdStanVB.stan_variables
778781
CmdStanGQ.stan_variables
782+
CmdStanLaplace.stan_variables
779783
"""
780784
result = {}
781785
for name in self._metadata.stan_vars:

cmdstanpy/stanfit/mle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ def stan_variable(
189189
--------
190190
CmdStanMLE.stan_variables
191191
CmdStanMCMC.stan_variable
192+
CmdStanPathfinder.stan_variable
192193
CmdStanVB.stan_variable
193194
CmdStanGQ.stan_variable
195+
CmdStanLaplace.stan_variable
194196
"""
195197
if var not in self._metadata.stan_vars:
196198
raise ValueError(
@@ -241,8 +243,10 @@ def stan_variables(
241243
--------
242244
CmdStanMLE.stan_variable
243245
CmdStanMCMC.stan_variables
246+
CmdStanPathfinder.stan_variables
244247
CmdStanVB.stan_variables
245248
CmdStanGQ.stan_variables
249+
CmdStanLaplace.stan_variables
246250
"""
247251
if not self.runset._check_retcodes():
248252
get_logger().warning(

cmdstanpy/stanfit/pathfinder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def stan_variable(self, var: str) -> np.ndarray:
106106
107107
See Also
108108
--------
109-
CmdStanMLE.stan_variables
109+
CmdStanPathfinder.stan_variables
110+
CmdStanMLE.stan_variable
110111
CmdStanMCMC.stan_variable
111112
CmdStanVB.stan_variable
112113
CmdStanGQ.stan_variable
@@ -133,10 +134,11 @@ def stan_variables(self) -> Dict[str, np.ndarray]:
133134
134135
See Also
135136
--------
136-
CmdStanGQ.stan_variable
137+
CmdStanPathfinder.stan_variable
137138
CmdStanMCMC.stan_variables
138139
CmdStanMLE.stan_variables
139140
CmdStanVB.stan_variables
141+
CmdStanGQ.stan_variables
140142
CmdStanLaplace.stan_variables
141143
"""
142144
result = {}

cmdstanpy/stanfit/vb.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def stan_variable(self, var: str) -> np.ndarray:
140140
CmdStanVB.stan_variables
141141
CmdStanMCMC.stan_variable
142142
CmdStanMLE.stan_variable
143+
CmdStanPathfinder.stan_variable
143144
CmdStanGQ.stan_variable
145+
CmdStanLaplace.stan_variable
144146
"""
145147
try:
146148
out: np.ndarray = self._metadata.stan_vars[var].extract_reshape(
@@ -166,6 +168,8 @@ def stan_variables(self) -> Dict[str, np.ndarray]:
166168
CmdStanMCMC.stan_variables
167169
CmdStanMLE.stan_variables
168170
CmdStanGQ.stan_variables
171+
CmdStanPathfinder.stan_variables
172+
CmdStanLaplace.stan_variables
169173
"""
170174
result = {}
171175
for name in self._metadata.stan_vars:

docsrc/api.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ API Reference
66

77
The following documents the public API of CmdStanPy. It is expected to be stable between versions,
88
with backwards compatibility between minor versions and deprecation warnings preceding breaking changes.
9-
There is also the `internal API <internal_api.rst>`__, which is makes no such guarantees.
9+
The documentation for the `internal API <internal_api.rst>`_ is also provided, but the internal API
10+
does not guarantee either stability and backwards compatibility.
1011

1112
.. toctree::
1213
:hidden:
@@ -25,15 +26,15 @@ A CmdStanModel object encapsulates the Stan program. It manages program compilat
2526
:meth:`~CmdStanModel.sample`
2627
runs the HMC-NUTS sampler to produce a set of draws from the posterior distribution.
2728

28-
:meth:`~CmdStanModel.pathfinder`
29-
runs the Pathfinder variational inference parameters to recieve approximate draws from the posterior.
30-
3129
:meth:`~CmdStanModel.optimize`
3230
produce a penalized maximum likelihood estimate or maximum a posteriori estimate (point estimate) of the model parameters.
3331

3432
:meth:`~CmdStanModel.laplace_sample`
3533
draw from a Laplace approximatation centered at the posterior mode found by ``optimize``.
3634

35+
:meth:`~CmdStanModel.pathfinder`
36+
runs the Pathfinder variational inference parameters to recieve approximate draws from the posterior.
37+
3738
:meth:`~CmdStanModel.variational`
3839
run CmdStan’s automatic differentiation variational inference (ADVI) algorithm to approximate the posterior distribution.
3940

@@ -43,30 +44,28 @@ A CmdStanModel object encapsulates the Stan program. It manages program compilat
4344
.. autoclass:: cmdstanpy.CmdStanModel
4445
:members:
4546

46-
4747
CmdStanMCMC
4848
===========
4949

5050
.. autoclass:: cmdstanpy.CmdStanMCMC
5151
:members:
5252

53-
54-
CmdStanPathfinder
55-
=================
56-
57-
.. autoclass:: cmdstanpy.CmdStanPathfinder
58-
:members:
59-
6053
CmdStanMLE
6154
==========
6255

6356
.. autoclass:: cmdstanpy.CmdStanMLE
6457
:members:
6558

66-
CmdStanGQ
67-
=========
59+
CmdStanLaplace
60+
==============
6861

69-
.. autoclass:: cmdstanpy.CmdStanGQ
62+
.. autoclass:: cmdstanpy.CmdStanLaplace
63+
:members:
64+
65+
CmdStanPathfinder
66+
=================
67+
68+
.. autoclass:: cmdstanpy.CmdStanPathfinder
7069
:members:
7170

7271
CmdStanVB
@@ -75,10 +74,10 @@ CmdStanVB
7574
.. autoclass:: cmdstanpy.CmdStanVB
7675
:members:
7776

78-
CmdStanLaplace
79-
==============
77+
CmdStanGQ
78+
=========
8079

81-
.. autoclass:: cmdstanpy.CmdStanLaplace
80+
.. autoclass:: cmdstanpy.CmdStanGQ
8281
:members:
8382

8483
*********

docsrc/changes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
What's New
66
==========
77

8-
For full changes, see the `Releases page <https://github.com/stan-dev/cmdstanpy/releases>`__ on GitHub.
8+
For full changes, see the `Releases page <https://github.com/stan-dev/cmdstanpy/releases>`_ on GitHub.
99

1010

1111
CmdStanPy 1.1.0

docsrc/community.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ Project templates
99
Templates are a great way to piggy back on other users' work, saving you time
1010
when you start a new project.
1111

12-
- `cookiecutter-cmdstanpy-analysis <https://github.com/teddygroves/cookiecutter-cmdstanpy-analysis>`__
12+
- `cookiecutter-cmdstanpy-analysis <https://github.com/teddygroves/cookiecutter-cmdstanpy-analysis>`_
1313
A cookiecutter template for cmdstanpy-based statistical analysis projects.
1414

15-
- `cookiecutter-cmdstanpy-wrapper <https://github.com/WardBrian/cookiecutter-cmdstanpy-wrapper>`__
15+
- `cookiecutter-cmdstanpy-wrapper <https://github.com/WardBrian/cookiecutter-cmdstanpy-wrapper>`_
1616
A cookiecutter template using Stan models in Python packages, including
1717
the ability to pre-compile the model as part of the package distribution.
1818

1919
Software
2020
--------
2121

22-
- `Prophet <https://github.com/facebook/prophet>`__ A procedure for forecasting
22+
- `Prophet <https://github.com/facebook/prophet>`_ A procedure for forecasting
2323
time series data based on an additive model where non-linear trends are fit
2424
with yearly, weekly, and daily seasonality, plus holiday effects.
2525

26-
- `ArviZ <https://github.com/arviz-devs/arviz>`__ A Python package (with a `Julia
27-
interface <https://julia.arviz.org/stable/>`__) for exploratory analysis of
26+
- `ArviZ <https://github.com/arviz-devs/arviz>`__ A Python package (with a
27+
`Julia interface <https://julia.arviz.org/stable/>`_) for exploratory analysis of
2828
Bayesian models. Includes functions for posterior analysis, data storage,
2929
model checking, comparison and diagnostics.
3030

31-
- `BridgeStan <https://github.com/roualdes/bridgestan>`__ A project which provides efficient
31+
- `BridgeStan <https://github.com/roualdes/bridgestan>`_ A project which provides efficient
3232
in-memory access through Python, Julia, and R to the methods of a Stan model, including
3333
log densities, gradients, Hessians, and constraining and unconstraining transforms.
3434

0 commit comments

Comments
 (0)