Skip to main content

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.

Quickstart

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"))
dag.plot()

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)
q.plot()

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

# we can also see updated probabilities
q.infer()
q.infer(give_table=True)

Documentation

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 0.0.0.0:12345 brent

Metadata

Release files for brent 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brent 0.2.4
File Size Uploaded
brent-0.2.4.tar.gz 18.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for brent 0.2.4
File Interpreter ABI Platform
brent-0.2.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 38.3 kB

Release files / brent-0.2.4.tar.gz

Download URL brent-0.2.4.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc6e95d8db74d7723fe6cfb4bcf17847001b379f34ea5329d33366519f3faf4d
BLAKE2b-256 checksum
How to use checksums
177f2ab14e09e6d7591b6814b1082cbf8a800882698cbed8474cf45ef2c8624f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6

Release files / brent-0.2.4-py2.py3-none-any.whl

Download URL brent-0.2.4-py2.py3-none-any.whl
Size 19.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f2cf21325b524c9a78e739c0059d8d6e944e94d4ff9a13df668fad837fb9186e
BLAKE2b-256 checksum
How to use checksums
c1149a98c480fc5ecbf7f06cdcb8e0c6bcc9d1c49d1a754fe1b7db3d24acb966
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page