--- id: pgmpy version: "1.1.2" license: The MIT License (MIT) Copyright (c) 2013 - present, pgmpy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) license_treatment: unclear maintenance: active --- # pgmpy — Python Toolkit for Causal and Probabilistic Reasoning License: unclear · Maintenance: active · Downloads: 957.9K/mo ## 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 above — verify before relying. pgmpy provides data structures and algorithms for causal discovery, causal inference, probabilistic inference, parameter learning, and model validation across Bayesian networks, DAGs, and structural equation models. 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 pip install pgmpy uv add pgmpy poetry add pgmpy ## Installing pgmpy 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. 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") Requires Python 3.10 or later (supports up to 3.14). All 12 runtime dependencies must be installed. 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: The MIT License (MIT) Copyright (c) 2013 - present, pgmpy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (unclear) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 957.9K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags bayesian network inference, causal discovery algorithms, probabilistic graphical models, causal inference do-calculus, structure learning from data, parameter estimation networks, counterfactual reasoning, causal-inference, graphical-models, probabilistic-reasoning [View on SkillFed](https://skillfed.io/packages/pgmpy) · [View on PyPI](https://pypi.org/project/pgmpy/)