PGMs that are fun to play with
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file peegeem-0.0.2.tar.gz.
File metadata
- Download URL: peegeem-0.0.2.tar.gz
- Upload date:
- Size: 10.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8c4cf5f252323b8640723903e3e17205812624e47d7d03230ab732126d4e2e7
|
|
| MD5 |
89a8eab17407fcc722be552fb069f3c1
|
|
| BLAKE2b-256 |
060e85bf7af087dfae80c3bcab4ca55acec901859a72dc6a527aa35645d6bcdc
|
File details
Details for the file peegeem-0.0.2-py3-none-any.whl.
File metadata
- Download URL: peegeem-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34940a154e92116700358dced88ee3a65da5a7eb7230c6ae3e04f9d03bfc4a4d
|
|
| MD5 |
c27f03429da677ec11a448e3304dbba3
|
|
| BLAKE2b-256 |
63dcf1b3466c302c757eb2d41b5124d5ccf6f6a8230f219133b51dfc092794a7
|