Skip to content
bayesian graphical modelling and a bit of do-calculus for discrete data.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
brent slight documentation change Mar 16, 2019
data found a bug and made a test for it! Feb 10, 2019
doc-settings maybe now the docs will work Feb 17, 2019
docs slight documentation change Mar 16, 2019
notebooks documentation img fix? Mar 16, 2019
.gitignore docs fix Feb 13, 2019
.travis.yml fixes minor flake8 issues and adds flake8 check to travis Mar 9, 2019
LICENSE Create LICENSE Mar 9, 2019
Makefile pypi fix Mar 9, 2019 also a setup Mar 15, 2019

Build Status Build status

They're good DAGs: brent.

What it is

Brent is a small, but fun, python library that makes it easy to explore causal graphical modelling and do-calculus on systems with discrete variables. Brent is a tool that can help out when you can write a system like below, but want to write complex queries on it.


You can install brent via pip:

pip install brent

Next we need to have a dataset and create a graph from it. The code below demonstrates how to do this.

from brent import DAG
from brent.common import make_fake_df

dag = (DAG(dataframe=make_fake_df(7))
       .add_edge("e", "a")
       .add_edge("e", "d")
       .add_edge("a", "d")
       .add_edge("b", "d")
       .add_edge("a", "b")
       .add_edge("a", "c")
       .add_edge("b", "c")
       .add_edge("c", "f")
       .add_edge("g", "f"))

Not only do we get pretty plots, but we also can build an expressive query on top of it.

from brent import Query
q = Query(dag).given(d=1).do(a=0, c=1)

If you're more interested in doing the inference, that's simple too.

# we can also see updated probabilities


Liked the quickstart? The documentation (which is generated with pdoc3) can be found here.

Alpha Notice

NOTE! this project is in preview stages. I think I have something fun here and I've written unit tests on what I'm doing but parts are still going under review. Also there are parts of the library currently missing but which are on a roadmap:

  1. conditional indepdence tests
  2. api for counterfactual queries
  3. more unit tests
  4. datasets to start/teach with
  5. clear logging
  6. estimator/transformers for scikit-learn

Developing Locally

After cloning you may install brent in the virtual environment via:

$ pip install -e ".[dev]"

You can generate documentation locally by running:

$ pdoc --html --overwrite --template-dir doc-settings --http brent
You can’t perform that action at this time.