Python toolkit for causal and probabilistic reasoning
pgmpy is a Python library for causal and probabilistic reasoning with graphical models. It covers the full workflow from learning causal graphs from data to estimating causal effects, running probabilistic inference, and simulating data from fitted models. All algorithms follow a unified, composable API and are scikit-learn compatible where possible, so they work standalone, in sklearn pipelines, or as building blocks for higher-level tools.
Key Features#
Learn causal graphs from data using scikit-learn compatible implementations.
Estimate conditional distributions for nodes in the model.
Compute posterior distributions from the learned model using exact or approximate inference.
Given a causal graph determine how to estimate the a causal query.
Compute interventional and counterfactual distributions from models.
Built-in collection of example Bayesian Networks and datasets from different sources.
Simulate data from models under various scenarios.
Write your own custom pgmpy plugable methods using our extension templates.