peegeem
Probabilistic graphical models that are fun to work with
This simple library is meant as a demo that shows what might be possible when you combine domain specific languages with bespoke UI tools. You might end up with a domain specific environment as a result!
Install
You can install via pip.
uv pip install peegeem
Usage
This is how you might use this experiment.
from peegeem import DAG
# Define the DAG for the PGM, nodes is a list of column names, edges is a list of tuples
dag = DAG(nodes, edges, dataframe)
# Get variables out
outcome, smoker, age = dag.get_variables()
# Use variables to construct a probablistic query
P(outcome | (smoker == "Yes") & (age > 40))
# Latex utility, why not?
P.to_latex(outcome | (smoker == "Yes") & (age > 40))
The goal is to have an API that really closely mimics the math notation, so stuff like this:
$$ P(\text{outcome} \mid do(\text{smoker}=\texttt{Yes}), \text{age}>40) $$
That means that we indeed also have a do function, though this needs more extensive testing.
# You can also get crazy fancy
P(A & B | C & do(D))
Demo
For a solid demo, download and run this notebook locally.
You can run the notebook in a sandboxed environment with uv. Navigate to the nbs directory and run:
uvx marimo edit --sandbox __init__.py
Metadata
Release files for peegeem 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| peegeem-0.0.2.tar.gz | 10.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| peegeem-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 MB
Release files / peegeem-0.0.2.tar.gz
| Download URL | peegeem-0.0.2.tar.gz |
|---|---|
| Size | 10.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8c4cf5f252323b8640723903e3e17205812624e47d7d03230ab732126d4e2e7
|
|
BLAKE2b-256 checksum How to use checksums |
060e85bf7af087dfae80c3bcab4ca55acec901859a72dc6a527aa35645d6bcdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.16
|
Release files / peegeem-0.0.2-py3-none-any.whl
| Download URL | peegeem-0.0.2-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34940a154e92116700358dced88ee3a65da5a7eb7230c6ae3e04f9d03bfc4a4d
|
|
BLAKE2b-256 checksum How to use checksums |
63dcf1b3466c302c757eb2d41b5124d5ccf6f6a8230f219133b51dfc092794a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.16
|