https://github.com/pymc-devs/symbolic-pymc
Tools for the symbolic manipulation of PyMC models, Theano, and TensorFlow graphs.
https://github.com/pymc-devs/symbolic-pymc
bayesian minikanren probabilistic-programming pymc relational-programming symbolic-computation symbolic-math tensorflow theano
Last synced: about 1 month ago
JSON representation
Tools for the symbolic manipulation of PyMC models, Theano, and TensorFlow graphs.
- Host: GitHub
- URL: https://github.com/pymc-devs/symbolic-pymc
- Owner: pymc-devs
- License: other
- Created: 2019-02-16T18:35:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T15:48:21.000Z (over 1 year ago)
- Last Synced: 2025-08-05T13:38:48.574Z (2 months ago)
- Topics: bayesian, minikanren, probabilistic-programming, pymc, relational-programming, symbolic-computation, symbolic-math, tensorflow, theano
- Language: Python
- Homepage: https://pymc-devs.github.io/symbolic-pymc
- Size: 3.79 MB
- Stars: 62
- Watchers: 22
- Forks: 8
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Symbolic PyMC
[](https://travis-ci.org/pymc-devs/symbolic-pymc) [](https://coveralls.io/github/pymc-devs/symbolic-pymc?branch=master)
[Symbolic PyMC](https://pymc-devs.github.io/symbolic-pymc) provides tools for the symbolic manipulation of [PyMC](https://github.com/pymc-devs) models and their underlying computational graphs in [Theano](https://github.com/Theano/Theano) and [TensorFlow](https://github.com/tensorflow/tensorflow). It enables graph manipulations in the relational DSL [miniKanren](http://minikanren.org/)—via the [`miniKanren`](https://github.com/pythological/kanren) package—by way of meta classes and S-expression forms of a graph.
This work stems from a series of articles starting [here](https://brandonwillard.github.io/a-role-for-symbolic-computation-in-the-general-estimation-of-statistical-models.html). Documentation and examples for Symbolic PyMC are available [here](https://pymc-devs.github.io/symbolic-pymc).
*This package is currently in alpha, so expect large-scale changes at any time!*
## Installation
The package name is `symbolic_pymc` and it can be installed with `pip` directly from GitHub
```shell
$ pip install git+https://github.com/pymc-devs/symbolic-pymc
```
or after cloning the repo (and then installing with `pip`).## Features
### General
* Support for [Theano](https://github.com/Theano/Theano) and [TensorFlow](https://github.com/tensorflow/tensorflow) graphs
- [Unification and reification](https://github.com/pythological/unification) for all components of a graph
- A more robust Theano `Op` for representing random variables
- Conversion of PyMC3 models into sample-able Theano graphs representing all random variable inter-dependencies
- A Theano LaTeX pretty printer that displays shape information and distributions in mathematical notation
- Simple text-based TensorFlow graph print-outs
* Full [miniKanren](http://minikanren.org/) integration for relational graph/model manipulation.
- Perform simple and robust "search and replace" over arbitrary graphs (e.g. Python builtin collections, AST, tensor algebra graphs, etc.)
- Create and compose relations with explicit high-level statistical/mathematical meaning and functionality, such as "`X` is a normal scale mixture with mixing distribution `Y`", and automatically "solve" for components (i.e. `X` and `Y`) that satisfy a relation
- Apply non-trivial conditions—as relations—to produce sophisticated graph manipulations (e.g. search for normal scale mixtures and scale a term in the mixing distribution)
- Integrate standard Python operations into relations (e.g. use a symbolic math library to compute an inverse-Laplace transform to determine if a distribution is a scale mixture—and find its mixing distribution)
* Convert graphs to an S-expression-like tuple-based form and perform manipulations at the syntax level
* Pre-built example relations for graph traversal, fixed-points, symbolic closed-form posteriors, and standard statistical model reformulations