Skip to main content

No project description provided

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brent-0.2.4.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

brent-0.2.4-py2.py3-none-any.whl (19.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file brent-0.2.4.tar.gz.

File metadata

  • Download URL: brent-0.2.4.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for brent-0.2.4.tar.gz
Algorithm Hash digest
SHA256 bc6e95d8db74d7723fe6cfb4bcf17847001b379f34ea5329d33366519f3faf4d
MD5 3915f832c3dc1630445f12f49ca3e39b
BLAKE2b-256 177f2ab14e09e6d7591b6814b1082cbf8a800882698cbed8474cf45ef2c8624f

See more details on using hashes here.

File details

Details for the file brent-0.2.4-py2.py3-none-any.whl.

File metadata

  • Download URL: brent-0.2.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for brent-0.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f2cf21325b524c9a78e739c0059d8d6e944e94d4ff9a13df668fad837fb9186e
MD5 e2bc85accd20977e679a42fa5b3a42b4
BLAKE2b-256 c1149a98c480fc5ecbf7f06cdcb8e0c6bcc9d1c49d1a754fe1b7db3d24acb966

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page