cgm

Causal Graphical Models


Keywords
cgm, pgm, dag, causal, inference, factors
License
MIT
Install
pip install cgm==0.0.4

Documentation

Causal Graphical Models

A python library for building causal graphical models, closely following Daphne Koller's Coursera course on Probabilistic Graphical Models, and her 2009 book Probabilistic Graphical Models: Principles and Techniques. The source for this project is available here.

Installation

NumPy is the only dependency. Python version must be >= 3.7.

pip install cgm

Usage

import numpy as np
import cgm

np.random.seed(30)
# Define all nodes
A = cgm.CG_Node('A', nStates=3)
B = cgm.CG_Node('B', 3)
C = cgm.CG_Node('C', 3)
D = cgm.CG_Node('D', 3)
# Specify all parents of nodes
cgm.CPD(child=B, parents=[A])
cgm.CPD(C, [B])
cgm.CPD(D, [A, B])
# Create causal graph
graph = cgm.CG([A, B, C, D])