https://github.com/aesara-devs/aeppl

Tools for an Aesara-based PPL.

https://github.com/aesara-devs/aeppl

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 14 committers (7.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

bayesian-statistics modeling-and-simulation ppl probability statistics symbolic-computation term-rewriting

Keywords from Contributors

optimizing-compiler automatic-differentiation transpiler probabilistic-programming theano term-rewriting-system tensors aesara bayesian-inference mcmc
Last synced: 5 months ago · JSON representation

Repository

Tools for an Aesara-based PPL.

Basic Info
Statistics
  • Stars: 66
  • Watchers: 2
  • Forks: 20
  • Open Issues: 44
  • Releases: 46
Topics
bayesian-statistics modeling-and-simulation ppl probability statistics symbolic-computation term-rewriting
Created over 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme Funding License Security

README.md

AePPL Logo # AePPL [![Pypi][pypi-badge]][pypi] [![Downloads][downloads-badge]][releases] [![Contributors][contributors-badge]][contributors]
[![Gitter][gitter-badge]][gitter] [![Discord][discord-badge]][discord] [![Twitter][twitter-badge]][twitter] Aeppl provides tools for a[e]PPL written in [Aesara](https://github.com/aesara-devs/aesara). *Build arbitrarily complex probabilistic models. If it is mathematically defined, AePPL will support it.* [Features](#features) • [Get started](#get-started) • [Install](#install) • [Get help](#get-help) • [Contribute](#contribute)

Features

  • Convert graphs containing Aesara RandomVariables into joint log-probability graphs
  • Transforms for RandomVariables that map constrained support spaces to unconstrained spaces (e.g. the extended real numbers), and a rewrite that automatically applies these transformations throughout a graph
  • Tools for traversing and transforming graphs containing RandomVariables
  • RandomVariable-aware pretty printing and LaTeX output

Get started

Using aeppl, one can create a joint log-density graph from a graph containing Aesara RandomVariables:

``` python import aesara from aesara import tensor as at

from aeppl import joint_logprob, pprint

srng = at.random.RandomStream()

A simple scale mixture model

Srv = srng.invgamma(0.5, 0.5) Yrv = srng.normal(0.0, at.sqrt(S_rv))

Compute the joint log-probability

logprob, (y, s) = jointlogprob(Yrv, S_rv) ```

Log-density graphs are standard Aesara graphs, so we can compute compile them to compute values:

``` python logprob_fn = aesara.function([y, s], logprob)

logprob_fn(-0.5, 1.0)

array(-2.46287705)

```

AePPL provides utilities to pretty-print the log-density graphs:

``` python from aeppl import pprint, latex_pprint

Print the original graph

print(pprint(Y_rv))

b ~ invgamma(0.5, 0.5) in R, a ~ N(0.0, sqrt(b)**2) in R

a

print(latexpprint(Yrv))

\begin{equation}

\begin{gathered}

b \sim \operatorname{invgamma}\left(0.5, 0.5\right)\, \in \mathbb{R}

\

a \sim \operatorname{N}\left(0.0, {\sqrt{b}}^{2}\right)\, \in \mathbb{R}

\end{gathered}

\

a

\end{equation}

Simplify the graph so that it's easier to read

from aesara.graph.rewriting.utils import rewritegraph from aesara.tensor.rewriting.basic import topoconstant_folding

logprob = rewritegraph(logprob, customrewrite=topoconstantfolding)

print(pprint(logprob))

s in R, y in R

(switch(s >= 0.0,

((-0.9189385175704956 +

switch(s == 0, -inf, (-1.5 * log(s)))) - (0.5 / s)),

-inf) +

((-0.9189385332046727 + (-0.5 * ((y / sqrt(s)) ** 2))) - log(sqrt(s))))

```

Joint log-densities can be computed for some terms that are derived from RandomVariables, as well:

``` python

Create a switching model from a Bernoulli distributed index

Zrv = srng.normal([-100, 100], 1.0, name="Z") Irv = srng.bernoulli(0.5, name="I")

Mrv = Zrv[Irv] Mrv.name = "M"

Compute the joint log-probability for the mixture

logprob, (m, z, i) = jointlogprob(Mrv, Zrv, Irv)

logprob = rewritegraph(logprob, customrewrite=topoconstantfolding)

print(pprint(logprob))

i in Z, m in R, a in Z

(switch((0 <= i and i <= 1), -0.6931472, -inf) +

((-0.9189385332046727 + (-0.5 * (((m - [-100 100][a]) / [1. 1.][a]) ** 2))) -

log([1. 1.][a])))

```

Take a look at the documentation for more examples.

Install

The latest release of aeppl can be installed from PyPI using pip:

bash pip install aeppl

Or via conda-forge:

bash conda install -c conda-forge aeppl

The nightly (bleeding edge) version of aeppl can be installed using pip:

bash pip install aeppl-nightly

Get help

Report bugs by opening an issue. If you have a question regarding the usage of AePPL, start a discussion or visit our Discord server and Gitter room chats.

Contribute

AePPL welcomes contributions. To start contributing, take a look at the open issues.

If you want to implement a new feature, open a discussion or come chat with us on Discord or Gitter.

Owner

  • Name: Aesara
  • Login: aesara-devs
  • Kind: organization
  • Email: aesara.devs@gmail.com

GitHub Events

Total
  • Watch event: 2
  • Push event: 2
Last Year
  • Watch event: 2
  • Push event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 253
  • Total Committers: 14
  • Avg Commits per committer: 18.071
  • Development Distribution Score (DDS): 0.387
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Brandon T. Willard b****d 155
Ricardo r****4@g****m 55
Rémi Louf r****f@g****m 26
Larry Dong l****g@m****a 7
lucianopaz l****o@g****m 1
kees ter brugge k****e@g****m 1
kc611 c****6@g****m 1
The Gitter Badger b****r@g****m 1
Oriol (ZBook) o****a@g****m 1
LeoKnaw 4****w 1
Kd-Here 9****e 1
Daniel Gerlanc d****n@g****m 1
Ben Mares s****1@t****m 1
Adrian Seyboldt a****t@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 89
  • Total pull requests: 103
  • Average time to close issues: 4 months
  • Average time to close pull requests: 26 days
  • Total issue authors: 8
  • Total pull request authors: 9
  • Average comments per issue: 2.38
  • Average comments per pull request: 3.16
  • Merged pull requests: 83
  • Bot issues: 0
  • Bot pull requests: 6
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • rlouf (16)
  • ricardoV94 (12)
  • brandonwillard (11)
  • larryshamalama (3)
  • junpenglao (2)
  • aseyboldt (1)
  • bwengals (1)
  • MauricioGS99 (1)
Pull Request Authors
  • brandonwillard (25)
  • ricardoV94 (11)
  • rlouf (10)
  • larryshamalama (4)
  • github-actions[bot] (2)
  • dependabot[bot] (2)
  • LeoKnaw (1)
  • Kd-Here (1)
  • dgerlanc (1)
Top Labels
Issue Labels
help wanted (23) enhancement (21) graph rewriting (13) bug (10) op-probability (8) rv-transforms (7) important (7) request discussion (6) good first issue (5) documentation (4) scan (3) refactoring (3) CI (2) testing (2) question (2) performance concern (1) invalid (1)
Pull Request Labels
enhancement (19) important (14) graph rewriting (13) bug (12) refactoring (12) documentation (9) op-probability (8) rv-transforms (6) testing (4) request discussion (3) CI (2) dependencies (2) question (1)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 182,831 last-month
  • Total docker downloads: 10
  • Total dependent packages: 11
    (may contain duplicates)
  • Total dependent repositories: 105
    (may contain duplicates)
  • Total versions: 867
  • Total maintainers: 3
pypi.org: aeppl

PPL tools for Aesara

  • Versions: 47
  • Dependent Packages: 4
  • Dependent Repositories: 93
  • Downloads: 154,790 Last month
  • Docker Downloads: 10
Rankings
Downloads: 1.2%
Dependent repos count: 1.5%
Dependent packages count: 1.9%
Docker downloads count: 4.1%
Average: 4.3%
Forks count: 8.2%
Stargazers count: 8.8%
Maintainers (3)
Last synced: 6 months ago
pypi.org: aeppl-nightly

PPL tools for Aesara

  • Versions: 779
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 28,041 Last month
Rankings
Downloads: 5.1%
Dependent packages count: 6.6%
Forks count: 8.2%
Stargazers count: 8.9%
Average: 11.9%
Dependent repos count: 30.6%
Maintainers (3)
Last synced: about 1 year ago
conda-forge.org: aeppl
  • Versions: 32
  • Dependent Packages: 5
  • Dependent Repositories: 8
Rankings
Dependent packages count: 10.4%
Dependent repos count: 12.2%
Average: 24.2%
Forks count: 35.4%
Stargazers count: 38.8%
Last synced: 6 months ago
conda-forge.org: aeppl-base
  • Versions: 9
  • Dependent Packages: 2
  • Dependent Repositories: 4
Rankings
Dependent repos count: 16.2%
Dependent packages count: 19.6%
Average: 27.5%
Forks count: 35.4%
Stargazers count: 38.8%
Last synced: 6 months ago

Dependencies

.github/workflows/nightly.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/pypi.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/test.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v2 composite
  • codecov/codecov-action v1 composite
  • conda-incubator/setup-miniconda v2 composite
  • dorny/paths-filter v2 composite
  • pre-commit/action v3.0.0 composite
.github/workflows/update-pre-commit.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • browniebroke/pre-commit-autoupdate-action main composite
  • peter-evans/create-pull-request v4 composite
requirements-docs.txt pypi
  • jinja2 <3.1.0
  • sphinx *
  • sphinx-autodoc-typehints *
  • sphinx-book-theme >=0.3.3
  • sphinx-copybutton *
  • sphinx-design *
requirements.txt pypi
  • autoflake *
  • black ==20.8b1
  • coveralls *
  • diff-cover *
  • numdifftools *
  • pre-commit *
  • pydocstyle >=3.0.0
  • pylint >=2.3.1
  • pytest >=5.0.0
  • pytest-cov >=2.6.1
  • pytest-html >=1.20.0
  • versioneer *
setup.py pypi
  • aesara >=2.8.13
  • numpy >=1.18.1
  • scipy >=1.4.0
  • typing_extensions *