pgmpy
Python Toolkit for Causal and Probabilistic Reasoning
Decision gist · record as of 2026-08-14
Yes. pgmpy is actively maintained, has low install friction, carries no security vulnerabilities, and offers a comprehensive toolkit for causal and probabilistic reasoning with a scikit-learn-compatible API. It is suitable for research, education, and production use in causal inference and graphical modeling tasks. The MIT license imposes no restrictions.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later (supports up to 3.14).
- All 12 runtime dependencies must be installed.
- Low install friction with a pure-Python wheel.
License · maintenance · safety
(unclear) — Licensed under MIT with no restrictions on commercial or private use, though license treatment is marked unclear in metadata.
last release 2026-04-30 (106 days) · last repo commit 2026-08-14 · 3,313 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 957,860 downloads/mo, #4,642 on PyPI
Alternatives
Verify before relying
pip install pgmpy
from pgmpy.example_models import load_model
from pgmpy.estimators import PC
discrete_bn = load_model("bnlearn/alarm")
alarm_df = discrete_bn.simulate(n_samples=100)
dag = PC(data=alarm_df).estimate(ci_test="chi_square", return_type="dag")- Whether all 12 runtime dependencies are always required or if some are optional for specific use cases.
- Performance characteristics or scalability limits for large graphical models.
- Whether torch backend support (mentioned in examples) requires additional optional dependencies.
What it is and what it does
pgmpy is a Python toolkit for building and reasoning with causal and probabilistic graphical models. It implements data structures for DAGs, Bayesian networks, dynamic Bayesian networks, and structural equation models, along with algorithms for causal discovery, causal identification, probabilistic and causal inference, parameter estimation, model validation, and simulation.
The package provides a unified, composable API across algorithms and is scikit-learn compatible where applicable, allowing use in sklearn pipelines or as standalone tools. It handles discrete data, linear Gaussian data, and mixture models with arbitrary relationships. The library is actively maintained, supports Python 3.10 through 3.14, and depends on standard scientific Python libraries.
Use it for
- Learn causal structure from observational data using algorithms like PC, then estimate parameters and make predictions.
- Compute posterior distributions conditioned on observed evidence in discrete or continuous Bayesian networks.
- Generate synthetic data under specified interventions or counterfactual scenarios using do-calculus.
- Validate whether a proposed causal structure is compatible with observed data using metrics.
- Build hybrid models mixing discrete and continuous variables with functional relationships.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pgmpy is actively maintained, has low install friction, carries no security vulnerabilities, and offers a comprehensive toolkit for causal and probabilistic reasoning with a scikit-learn-compatible API. It is suitable for research, education, and production use in causal inference and graphical modeling tasks. The MIT license imposes no restrictions.
Install
pgmpy on PyPI
Before you install
Low install friction with a pure-Python wheel. Maintenance is active with a recent release and 3313 GitHub stars. Depends on 12 well-established scientific libraries including networkx, numpy, scipy, scikit-learn, pandas, and statsmodels.
Requires Python 3.10 or later (supports up to 3.14). All 12 runtime dependencies must be installed.
License in practice
Licensed under MIT with no restrictions on commercial or private use, though license treatment is marked unclear in metadata.
Quickstart
pip install pgmpy
from pgmpy.example_models import load_model
from pgmpy.estimators import PC
discrete_bn = load_model("bnlearn/alarm")
alarm_df = discrete_bn.simulate(n_samples=100)
dag = PC(data=alarm_df).estimate(ci_test="chi_square", return_type="dag")
Verify before relying
- Whether all 12 runtime dependencies are always required or if some are optional for specific use cases.
- Performance characteristics or scalability limits for large graphical models.
- Whether torch backend support (mentioned in examples) requires additional optional dependencies.
Package facts
| License | Not declared unclear |
| Python support | Supports the current Python release <3.15,>=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 12 packageshuggingface_hubnetworkxnumpyscipyscikit-learnpandasstatsmodelstqdmpyparsingjoblibopt_einsumscikit-base |
| Maintenance | Actively maintained 106 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 957,860 / month, #4,642 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: EducationIntended Audience :: Science/ResearchOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Bio-Informatics |
Evidence: pgmpy-1.1.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “causal discovery algorithms”
- pgmpypgmpy provides data structures and algorithms for causal discovery,…
- dowhyDoWhy is a Python library for causal inference that identifies and…
- psmpyPsmPy implements propensity score matching for observational studies,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Scientific/Engineering packages
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
pandas provides fast, flexible data structures (Series and DataFrame) for loading, cleaning, transforming, and analyzing labeled or relational data in Python.
scipy provides numerical algorithms for mathematics, science, and engineering—including optimization, integration, linear algebra, Fourier transforms, signal and image processing, and ODE solvers—built on numpy arrays.
scikit-learn provides a comprehensive Python library for supervised and unsupervised machine learning, including classification, regression, clustering, dimensionality reduction, and model evaluation tools built on NumPy and SciPy.
Install it if you need to train, evaluate, or deploy supervised or unsupervised learning models.
dill extends Python's pickle module to serialize and deserialize a much wider range of Python objects, including functions, lambdas, classes, and interpreter sessions, to byte streams for storage or network transmission.
Multiprocess is an enhanced fork of Python's standard multiprocessing library that uses dill for better serialization, allowing you to spawn processes with a threading-like API and share complex objects between them.
Install it if you use multiprocessing and encounter pickle serialization limits with lambdas or complex objects.
See also pyAgrum-nightly · pyjpt · dowhy · problog · causallib · causalml · pymc · tensorflow-probability · pymc3 · google-meridian