diff --git a/docs/source/api.rst b/docs/source/api.rst index c52f1b5969..b62b9145c7 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -10,11 +10,18 @@ API Reference api/distributions api/gp api/model - api/ode api/samplers + api/vi api/smc - api/step_methods - api/inference + api/backends + api/data + api/bart + api/ode + api/tuning + api/math + api/aesaraf + api/shape_utils + api/misc -------------- API extensions diff --git a/docs/source/api/aesaraf.rst b/docs/source/api/aesaraf.rst new file mode 100644 index 0000000000..e55cb37ca6 --- /dev/null +++ b/docs/source/api/aesaraf.rst @@ -0,0 +1,25 @@ +Aesara utils +************ + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + gradient + hessian + hessian_diag + inputvars + cont_inputs + floatX + intX + smartfloatX + jacobian + CallableTensor + join_nonshared_inputs + make_shared_replacements + generator + set_at_rng + at_rng + take_along_axis + pandas_to_array diff --git a/docs/source/api/backends.rst b/docs/source/api/backends.rst new file mode 100644 index 0000000000..c5c48d8523 --- /dev/null +++ b/docs/source/api/backends.rst @@ -0,0 +1,23 @@ +Storage backends +**************** + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + to_inference_data + predictions_to_inference_data + +Internal structures +------------------- + +.. automodule:: pymc.backends + +.. autosummary:: + :toctree: generated/ + + NDArray + point_list_to_multitrace + base.BaseTrace + base.MultiTrace diff --git a/docs/source/api/bart.rst b/docs/source/api/bart.rst new file mode 100644 index 0000000000..4ee4325678 --- /dev/null +++ b/docs/source/api/bart.rst @@ -0,0 +1,12 @@ +Bayesian Additive Regression Trees (BART) +***************************************** + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + BART + PGBART + bart.plot_dependence + bart.predict diff --git a/docs/source/api/data.rst b/docs/source/api/data.rst new file mode 100644 index 0000000000..004d7ff75e --- /dev/null +++ b/docs/source/api/data.rst @@ -0,0 +1,15 @@ +Data +**** + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + ConstantData + MutableData + get_data + Data + GeneratorAdapter + Minibatch + align_minibatches diff --git a/docs/source/api/inference.rst b/docs/source/api/inference.rst deleted file mode 100644 index ad7c54f37c..0000000000 --- a/docs/source/api/inference.rst +++ /dev/null @@ -1,113 +0,0 @@ -********* -Inference -********* - -Sampling --------- - -.. currentmodule:: pymc.sampling - -.. automodule:: pymc.sampling - :members: - - -Step-methods -^^^^^^^^^^^^ - -.. currentmodule:: pymc.sampling - -.. autofunction:: pymc.sampling.assign_step_methods - - -NUTS -~~~~ - -.. currentmodule:: pymc.step_methods.hmc.nuts - -.. automodule:: pymc.step_methods.hmc.nuts - :members: - -Metropolis -~~~~~~~~~~ - -.. currentmodule:: pymc.step_methods.metropolis -odule:: pymc.step_methods.metropolis - :members: -.. autom - -Slice -~~~~~ - -.. currentmodule:: pymc.step_methods.slicer - -.. automodule:: pymc.step_methods.slicer - :members: - -Hamiltonian Monte Carlo -~~~~~~~~~~~~~~~~~~~~~~~ - -.. currentmodule:: pymc.step_methods.hmc.hmc - -.. autoclass:: pymc.step_methods.hmc.hmc.HamiltonianMC - :members: - -MultiTrace -^^^^^^^^^^ - -.. currentmodule:: pymc.backends.base -.. autoclass:: pymc.backends.base.MultiTrace - :members: - -.. autoclass:: pymc.backends.base.BaseTrace - -Variational Inference ---------------------- - -OPVI -^^^^ - -.. currentmodule:: pymc.variational.opvi - -.. automodule:: pymc.variational.opvi - :members: - -VI Inference API -^^^^^^^^^^^^^^^^ - -.. currentmodule:: pymc.variational.inference - -.. automodule:: pymc.variational.inference - :members: - -Approximations -^^^^^^^^^^^^^^ - -.. currentmodule:: pymc.variational.approximations - -.. automodule:: pymc.variational.approximations - :members: - -Operators -^^^^^^^^^ - -.. currentmodule:: pymc.variational.operators - -.. automodule:: pymc.variational.operators - :members: - - -Sequential Monte Carlo ----------------------- - -.. currentmodule:: pymc.smc.sample_smc - -.. automodule:: pymc.smc.sample_smc - :members: - -Kernels -^^^^^^^ - -.. currentmodule:: pymc.smc.smc - -.. automodule:: pymc.smc.smc - :members: diff --git a/docs/source/api/math.rst b/docs/source/api/math.rst index 3f7ceeb99c..c471a7bf8b 100644 --- a/docs/source/api/math.rst +++ b/docs/source/api/math.rst @@ -7,9 +7,27 @@ from aesara.tensor (see there for more details). Doing any kind of math with PyM variables, or defining custom likelihoods or priors requires you to use these Aesara expressions rather than NumPy or Python code. -.. currentmodule:: pymc.math +.. currentmodule:: pymc +Functions exposed in pymc namespace +----------------------------------- .. autosummary:: + :toctree: generated/ + + expand_packed_triangular + logit + invlogit + probit + invprobit + logsumexp + +Functions exposed in pymc.math +------------------------------ + +.. automodule:: pymc.math +.. autosummary:: + :toctree: generated/ + dot constant flatten @@ -58,6 +76,3 @@ expressions rather than NumPy or Python code. logsumexp invlogit logit - -.. automodule:: pymc.math - :members: diff --git a/docs/source/api/misc.rst b/docs/source/api/misc.rst new file mode 100644 index 0000000000..3cf81553e0 --- /dev/null +++ b/docs/source/api/misc.rst @@ -0,0 +1,19 @@ +Other utils +*********** + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + find_constrained_prior + DictToArrayBijection + +Printing +-------- +.. autosummary:: + :toctree: generated/ + + str_for_dist + str_for_model + str_for_potential_or_deterministic diff --git a/docs/source/api/model.rst b/docs/source/api/model.rst index 13da8f6f55..81bf12711a 100644 --- a/docs/source/api/model.rst +++ b/docs/source/api/model.rst @@ -1,6 +1,25 @@ Model ----- -.. currentmodule:: pymc.model -.. automodule:: pymc.model - :members: +Model creation and inspection +----------------------------- + +.. currentmodule:: pymc +.. autosummary:: + :toctree: generated/ + + Model + model_to_graphviz + modelcontext + +Others +------ + +.. autosummary:: + :toctree: generated/ + + Deterministic + Potential + set_data + Point + compile_fn diff --git a/docs/source/api/ode.rst b/docs/source/api/ode.rst index f99585c4b7..4a532577b1 100644 --- a/docs/source/api/ode.rst +++ b/docs/source/api/ode.rst @@ -2,11 +2,10 @@ Ordinary differential equations (ODEs) ************************************** -This submodule contains tools used to perform inference on ordinary differential equations. -.. currentmodule:: pymc.ode +.. automodule:: pymc.ode .. autosummary:: + :toctree: generated/ -.. automodule:: pymc.ode - :members: DifferentialEquation + DifferentialEquation diff --git a/docs/source/api/samplers.rst b/docs/source/api/samplers.rst index e36c0e4b82..2e4a4cad13 100644 --- a/docs/source/api/samplers.rst +++ b/docs/source/api/samplers.rst @@ -1,13 +1,72 @@ -==== Samplers -==== +======== -This submodule contains functions for MCMC sampling. +This submodule contains functions for MCMC and forward sampling. -.. currentmodule:: pymc.sampling +.. currentmodule:: pymc .. autosummary:: + :toctree: generated/ -.. automodule:: pymc.sampling - :members: + sample + sample_prior_predictive + sample_posterior_predictive + sample_posterior_predictive_w + iter_sample + init_nuts + draw + +Step methods +************ + +.. currentmodule:: pymc + +HMC family +---------- + +.. autosummary:: + :toctree: generated/ + + NUTS + HamiltonianMC + +Metropolis family +----------------- + +.. autosummary:: + :toctree: generated/ + + BinaryGibbsMetropolis + BinaryMetropolis + CategoricalGibbsMetropolis + CauchyProposal + DEMetropolis + DEMetropolisZ + LaplaceProposal + Metropolis + MultivariateNormalProposal + NormalProposal + PoissonProposal + UniformProposal + +MLDA family +----------- + +.. autosummary:: + :toctree: generated/ + + MLDA + DEMetropolisZMLDA + MetropolisMLDA + RecursiveDAProposal + +Other step methods +------------------ + +.. autosummary:: + :toctree: generated/ + + CompoundStep + EllipticalSlice + Slice diff --git a/docs/source/api/shape_utils.rst b/docs/source/api/shape_utils.rst index f85f402405..29485dd4fb 100644 --- a/docs/source/api/shape_utils.rst +++ b/docs/source/api/shape_utils.rst @@ -11,6 +11,7 @@ This module introduces functions that are made aware of the requested `size_tupl .. currentmodule:: pymc.distributions.shape_utils .. autosummary:: + :toctree: generated/ to_tuple shapes_broadcasting @@ -18,6 +19,4 @@ This module introduces functions that are made aware of the requested `size_tupl get_broadcastable_dist_samples broadcast_distribution_samples broadcast_dist_samples_to - -.. automodule:: pymc.distributions.shape_utils - :members: + rv_size_is_none diff --git a/docs/source/api/smc.rst b/docs/source/api/smc.rst index ddac99d27c..671ea57662 100644 --- a/docs/source/api/smc.rst +++ b/docs/source/api/smc.rst @@ -1,8 +1,21 @@ -************* Sequential Monte Carlo -************* +********************** -.. toctree:: +.. automodule:: pymc.smc - smc/sample_smc - smc/smc +.. autosummary:: + :toctree: generated/ + + sample_smc + +(smc_kernels)= +SMC kernels +----------- + +.. currentmodule:: pymc.smc.smc +.. autosummary:: + :toctree: generated/ + + SMC_KERNEL + IMH + MH diff --git a/docs/source/api/smc/sample_smc.rst b/docs/source/api/smc/sample_smc.rst deleted file mode 100644 index b20681d1f0..0000000000 --- a/docs/source/api/smc/sample_smc.rst +++ /dev/null @@ -1,9 +0,0 @@ -*********************************** -Sample Sequential Monte Carlo (SMC) -*********************************** - -.. currentmodule:: pymc.smc.sample_smc -.. autosummary:: - sample_smc - -.. autofunction:: pymc.smc.sample_smc diff --git a/docs/source/api/smc/smc.rst b/docs/source/api/smc/smc.rst deleted file mode 100644 index 92e849e1e8..0000000000 --- a/docs/source/api/smc/smc.rst +++ /dev/null @@ -1,12 +0,0 @@ -**************************** -Sequential Monte Carlo (SMC) -**************************** - -.. currentmodule:: pymc.smc.smc -.. autosummary:: - SMC_KERNEL - IMH - MH - -.. automodule:: pymc.smc.smc - :members: diff --git a/docs/source/api/tuning.rst b/docs/source/api/tuning.rst new file mode 100644 index 0000000000..2535fe5d52 --- /dev/null +++ b/docs/source/api/tuning.rst @@ -0,0 +1,12 @@ +Tuning +------ + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + find_hessian + guess_scaling + trace_cov + find_MAP diff --git a/docs/source/api/vi.rst b/docs/source/api/vi.rst new file mode 100644 index 0000000000..af3b6ccdd5 --- /dev/null +++ b/docs/source/api/vi.rst @@ -0,0 +1,70 @@ +********************* +Variational Inference +********************* + +.. currentmodule:: pymc + +.. autosummary:: + :toctree: generated/ + + ADVI + ASVGD + NFVI + SVGD + FullRankADVI + ImplicitGradient + Inference + KLqp + fit + +Approximations +-------------- + +.. autosummary:: + :toctree: generated/ + + Empirical + FullRank + MeanField + NormalizingFlow + sample_approx + +OPVI +---- + +.. autosummary:: + :toctree: generated/ + + Approximation + Group + +Operators +--------- + +.. automodule:: pymc.variational.operators +.. autosummary:: + :toctree: generated/ + + KL + KSD + +Special +------- +.. currentmodule:: pymc +.. autosummary:: + :toctree: generated/ + + Stein + adadelta + adagrad + adagrad_window + adam + adamax + apply_momentum + apply_nesterov_momentum + momentum + nesterov_momentum + norm_constraint + rmsprop + sgd + total_norm_constraint diff --git a/docs/source/conf.py b/docs/source/conf.py index 854d0a151a..6d369fecc5 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -70,6 +70,11 @@ "ndarray": ":class:`~numpy.ndarray`", "Covariance": ":mod:`Covariance `", "Mean": ":mod:`Mean `", + "InferenceData": ":class:`arviz.InferenceData`", + "MultiTrace": ":class:`~pymc.backends.base.MultiTrace`", + "BaseTrace": ":class:`~pymc.backends.base.BaseTrace`", + "Point": ":class:`~pymc.Point`", + "SMC_kernel": ":ref:`SMC Kernel `", } # Show the documentation of __init__ and the class docstring @@ -179,6 +184,7 @@ "myst": ("https://myst-parser.readthedocs.io/en/latest", None), "myst-nb": ("https://myst-nb.readthedocs.io/en/latest/", None), "python": ("https://docs.python.org/3/", None), + "xarray": ("https://xarray.pydata.org/en/stable/", None), } diff --git a/pymc/__init__.py b/pymc/__init__.py index b02e1ea902..624e12d31f 100644 --- a/pymc/__init__.py +++ b/pymc/__init__.py @@ -51,7 +51,7 @@ def __set_compiler_flags(): from pymc import gp, ode, sampling from pymc.aesaraf import * -from pymc.backends import predictions_to_inference_data, to_inference_data +from pymc.backends import * from pymc.backends.tracetab import * from pymc.bart import * from pymc.blocking import * diff --git a/pymc/backends/__init__.py b/pymc/backends/__init__.py index 3c0236ed88..fbc9f971d3 100644 --- a/pymc/backends/__init__.py +++ b/pymc/backends/__init__.py @@ -62,3 +62,5 @@ """ from pymc.backends.arviz import predictions_to_inference_data, to_inference_data from pymc.backends.ndarray import NDArray, point_list_to_multitrace + +__all__ = ["to_inference_data", "predictions_to_inference_data"] diff --git a/pymc/distributions/__init__.py b/pymc/distributions/__init__.py index c1fe94c684..8134addf85 100644 --- a/pymc/distributions/__init__.py +++ b/pymc/distributions/__init__.py @@ -81,6 +81,7 @@ Discrete, Distribution, NoDistribution, + SymbolicDistribution, ) from pymc.distributions.mixture import Mixture, MixtureSameFamily, NormalMixture from pymc.distributions.multivariate import ( @@ -152,6 +153,7 @@ "OrderedProbit", "DensityDist", "Distribution", + "SymbolicDistribution", "Continuous", "Discrete", "NoDistribution", diff --git a/pymc/distributions/distribution.py b/pymc/distributions/distribution.py index 20f636b99c..ac2f43a6aa 100644 --- a/pymc/distributions/distribution.py +++ b/pymc/distributions/distribution.py @@ -56,6 +56,7 @@ "DensityDistRV", "DensityDist", "Distribution", + "SymbolicDistribution", "Continuous", "Discrete", "NoDistribution", diff --git a/pymc/math.py b/pymc/math.py index 6ba6fcab4e..ecbd1809c0 100644 --- a/pymc/math.py +++ b/pymc/math.py @@ -89,6 +89,76 @@ # pylint: enable=unused-import +__all__ = [ + "abs_", + "and_", + "ceil", + "clip", + "concatenate", + "constant", + "cos", + "cosh", + "dot", + "eq", + "erf", + "erfc", + "erfcinv", + "erfinv", + "exp", + "flatten", + "floor", + "ge", + "gt", + "le", + "log", + "log1pexp", + "logaddexp", + "logsumexp", + "lt", + "maximum", + "minimum", + "neq", + "ones_like", + "or_", + "prod", + "sgn", + "sigmoid", + "sin", + "sinh", + "sqr", + "sqrt", + "stack", + "sum", + "switch", + "tan", + "tanh", + "where", + "zeros_like", + "kronecker", + "cartesian", + "kron_dot", + "kron_solve_lower", + "kron_solve_upper", + "kron_diag", + "flat_outer", + "logdiffexp", + "logdiffexp_numpy", + "invlogit", + "softmax", + "log_softmax", + "logbern", + "logit", + "log1mexp", + "log1mexp_numpy", + "flatten_list", + "logdet", + "probit", + "invprobit", + "expand_packed_triangular", + "batched_diag", + "block_diagonal", +] + def kronecker(*Ks): r"""Return the Kronecker product of arguments: diff --git a/pymc/ode/__init__.py b/pymc/ode/__init__.py index 6033da9dd2..95fe0643f9 100644 --- a/pymc/ode/__init__.py +++ b/pymc/ode/__init__.py @@ -1,3 +1,4 @@ +"""This submodule contains tools used to perform inference on ordinary differential equations.""" # Copyright 2020 The PyMC Developers # # Licensed under the Apache License, Version 2.0 (the "License");