pgmpy/pgmpy

Python Toolkit for Causal and Probabilistic Reasoning

What it solves

pgmpy is a library for causal and probabilistic reasoning using graphical models. It allows users to build, learn, and perform inference on models that represent complex dependencies between variables, enabling the discovery of causal relationships and the calculation of probabilities based on observed evidence.

How it works

The library implements various data structures for graphical models, including Bayesian Networks, Dynamic Bayesian Networks, and Structural Equation Models. It provides a modular, composable API for tasks such as:

  • Causal Discovery: Learning the model structure from data or expert knowledge.
  • Parameter Learning: Estimating conditional probability distributions from observed data.
  • Probabilistic Inference: Computing posterior distributions based on evidence.
  • Causal Inference: Computing interventional distributions.
  • Simulations: Generating synthetic data under specific interventions or evidence.

Who it’s for

It is designed for researchers and developers who need to perform probabilistic graphical modeling, causal discovery, and causal inference in Python, with compatibility for scikit-learn pipelines.

Highlights

  • Diverse Model Support: Supports DAGs, PDAGs, MAGs, PAGs, and Linear Gaussian Bayesian Networks.
  • Causal Tooling: Integrated tools for causal discovery, identification, and validation.
  • Causal and Probabilistic Inference: Ability to compute both posterior and interventional distributions.
  • Scikit-learn Compatible: Modular API that can be integrated into standard ML pipelines.
  • Flexible Data Handling: Supports discrete, linear Gaussian, and mixture data with arbitrary relationships via Functional Bayesian Networks.

Related

  • Project
  • Project
  • Project
  • Project
  • Project