{"id":13418392,"url":"https://github.com/pgmpy/pgmpy","last_synced_at":"2025-05-15T00:00:45.674Z","repository":{"id":10718767,"uuid":"12968651","full_name":"pgmpy/pgmpy","owner":"pgmpy","description":"Python Library for Causal and Probabilistic Modeling using Bayesian Networks","archived":false,"fork":false,"pushed_at":"2025-05-07T08:56:00.000Z","size":13742,"stargazers_count":2894,"open_issues_count":295,"forks_count":753,"subscribers_count":75,"default_branch":"dev","last_synced_at":"2025-05-07T23:30:53.015Z","etag":null,"topics":["bayesian-networks","causal-discovery","causal-identification","causal-inference","causal-models","causal-validation","mixed-data","probabilistic-inference","python","simulation","synthetic-data"],"latest_commit_sha":null,"homepage":"https://pgmpy.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgmpy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"Contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["pgmpy"]}},"created_at":"2013-09-20T08:18:58.000Z","updated_at":"2025-05-07T13:14:40.000Z","dependencies_parsed_at":"2023-10-21T12:42:11.533Z","dependency_job_id":"bb72f29c-c647-4c0f-bb13-1f7a9054639c","html_url":"https://github.com/pgmpy/pgmpy","commit_stats":{"total_commits":2367,"total_committers":120,"mean_commits":19.725,"dds":"0.48753696662441914","last_synced_commit":"0f2767822d12293bbad05fa4d47c59f38cdd7ea0"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgmpy%2Fpgmpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgmpy%2Fpgmpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgmpy%2Fpgmpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgmpy%2Fpgmpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgmpy","download_url":"https://codeload.github.com/pgmpy/pgmpy/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249199,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian-networks","causal-discovery","causal-identification","causal-inference","causal-models","causal-validation","mixed-data","probabilistic-inference","python","simulation","synthetic-data"],"created_at":"2024-07-30T22:01:01.749Z","updated_at":"2025-05-15T00:00:45.591Z","avatar_url":"https://github.com/pgmpy.png","language":"Python","readme":"\u003cdiv\u003e\n\n\u003ca href=\"https://www.pgmpy.org\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/pgmpy/pgmpy/dev/logo/logo_color.png\" width=\"175\" align=\"left\" /\u003e\u003c/a\u003e\npgmpy is a Python library for causal and probabilistic modeling using Bayesian Networks and related models. It provides a uniform API for building, learning, and analyzing models such as Bayesian Networks, Dynamic Bayesian Networks, Directed Acyclic Graphs (DAGs), and Structural Equation Models(SEMs). By integrating tools from both probabilistic inference and causal inference, pgmpy enables users to seamlessly transition between predictive and interventional analyses.\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![Build](https://github.com/pgmpy/pgmpy/actions/workflows/ci.yml/badge.svg?branch=dev)\n[![codecov](https://codecov.io/gh/pgmpy/pgmpy/branch/dev/graph/badge.svg?token=UaJMCdHaEF)](https://codecov.io/gh/pgmpy/pgmpy)\n[![Version](https://img.shields.io/pypi/v/pgmpy?color=blue)](https://pypi.org/project/pgmpy/)\n[![!conda](https://img.shields.io/conda/vn/conda-forge/pgmpy)](https://anaconda.org/conda-forge/pgmpy) [![Python Version](https://img.shields.io/pypi/pyversions/pgmpy.svg?color=blue)](https://pypi.org/project/pgmpy/)\n[![License](https://img.shields.io/github/license/pgmpy/pgmpy)](https://github.com/pgmpy/pgmpy/blob/dev/LICENSE)\n[![Downloads](https://img.shields.io/pypi/dm/pgmpy.svg)](https://pypistats.org/packages/pgmpy)\n[![asv](http://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat)](http://pgmpy.org/pgmpy-benchmarks/)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Join the pgmpy Discord server](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge\u0026logo=discord\u0026logoColor=white)](https://discord.gg/DRkdKaumBs)\n[![Read the Docs](https://img.shields.io/badge/-Docs-blue?style=for-the-badge\u0026logo=Read-the-Docs\u0026logoColor=white\u0026link=https://inseq.org)](https://pgmpy.org)\n[![Examples](https://img.shields.io/badge/-Examples-orange?style=for-the-badge\u0026logo=Jupyter\u0026logoColor=white\u0026link=https://github.com/pgmpy/pgmpy/tree/dev/examples)](https://github.com/pgmpy/pgmpy/tree/dev/examples)\n[![Tutorial](https://img.shields.io/badge/-Tutorial-orange?style=for-the-badge\u0026logo=Jupyter\u0026logoColor=white\u0026link=https://github.com/pgmpy/pgmpy_notebook)](https://github.com/pgmpy/pgmpy_notebook)\n\n\u003c/div\u003e\n\n### Key Features\n\n| Feature | Description |\n|--------|-------------|\n| [**Causal Discovery / Structure Learning**](https://pgmpy.org/examples/Structure%20Learning%20in%20Bayesian%20Networks.html) | Learn the model structure from data, with optional integration of **expert knowledge**. |\n| [**Causal Validation**](https://pgmpy.org/metrics/metrics.html) | Assess how compatible the causal structure is with the data. |\n| [**Parameter Learning**](https://pgmpy.org/examples/Learning%20Parameters%20in%20Discrete%20Bayesian%20Networks.html) | Estimate model parameters (e.g., conditional probability distributions) from observed data. |\n| [**Probabilistic Inference**](https://pgmpy.org/examples/Inference%20in%20Discrete%20Bayesian%20Networks.html) | Compute posterior distributions conditioned on observed evidence. |\n| [**Causal Inference**](https://pgmpy.org/examples/Causal%20Inference.html) | Compute interventional and counterfactual distributions using do-calculus. |\n| [**Simulations**](https://github.com/pgmpy/pgmpy/blob/dev/examples/Simulating_Data.ipynb) | Generate synthetic data under specified evidence or interventions. |\n\n### Resources and Links\n- **Example Notebooks:** [Examples](https://github.com/pgmpy/pgmpy/tree/dev/examples)\n- **Tutorial Notebooks:** [Tutorials](https://github.com/pgmpy/pgmpy_notebook)\n- **Blog Posts:** [Medium](https://medium.com/@ankurankan_23083)\n- **Documentation:** [Website](https://pgmpy.org/)\n- **Bug Reports and Feature Requests:** [GitHub Issues](https://github.com/pgmpy/pgmpy/issues)\n- **Questions:** [discord](https://discord.gg/DRkdKaumBs) · [Stack Overflow](https://stackoverflow.com/questions/tagged/pgmpy)\n\n## Quickstart\n\n### Installation\npgmpy is available on both [PyPI](https://pypi.org/project/pgmpy/) and [anaconda](https://anaconda.org/conda-forge/pgmpy). To install from PyPI, use:\n\n```bash\npip install pgmpy\n```\nTo install from conda-forge, use:\n\n```bash\nconda install conda-forge::pgmpy\n```\n\n### Discrete Data\n```python\nfrom pgmpy.utils import get_example_model\n\n# Load a Discrete Bayesian Network and simulate data.\ndiscrete_bn = get_example_model('alarm')\nalarm_df = discrete_bn.simulate(n_samples=100)\n\n# Learn a network from simulated data.\nfrom pgmpy.estimators import PC\ndag = PC(data=alarm_df).estimate(ci_test='chi_square', return_type='dag')\n\n# Learn the parameters from the data.\ndag_fitted = dag.fit(alarm_df)\ndag_fitted.get_cpds()\n\n# Drop a column and predict using the learned model.\nevidence_df = alarm_df.drop(columns=['FIO2'], axis=1)\npred_FIO2 = dag_fitted.predict(evidence_df)\n```\n\n### Linear Gaussian Data\n```python\n# Load an example Gaussian Bayesian Network and simulate data\ngaussian_bn = get_example_model('ecoli70')\necoli_df = gaussian_bn.simulate(n_samples=100)\n\n# Learn the network from simulated data.\nfrom pgmpy.estimators import PC\ndag = PC(data=ecoli_df).estimate(ci_test='pearsonr', return_type='dag')\n\n# Learn the parameters from the data.\nfrom pgmpy.models import LinearGausianBayesianNetwork\ngaussian_bn = LinearGausianBayesianNetwork(dag.edges())\ndag_fitted = gaussian_bn.fit(ecoli_df)\ndag_fitted.get_cpds()\n\n# Drop a column and predict using the learned model.\nevidence_df = ecoli_df.drop(columns=['ftsJ'], axis=1)\npred_ftsJ = dag_fitted.predict(evidence_df)\n```\n\n## Contributing\n\nWe welcome all contributions --not just code-- to pgmpy. Please refer out\n[contributing guide](https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)\nfor more details. We also offer mentorship for new contributors and maintain a\nlist of potential [mentored\nprojects](https://github.com/pgmpy/pgmpy/wiki/Mentored-Projects). If you are\ninterested in contributing to pgmpy, please join our\n[discord](https://discord.gg/DRkdKaumBs) server and introduce yourself. We will\nbe happy to help you get started.\n","funding_links":["https://github.com/sponsors/pgmpy"],"categories":["Probabilistic Programming","Machine Learning","Probabilistic Methods","Table of Contents","Python","Probabilistic Graphical Models","\u003cspan id=\"head50\"\u003e3.6. Probablistic Machine Learning and Deep Learning\u003c/span\u003e","Linear Algebra / Statistics Toolkit","概率统计","其他_机器视觉","🎲 Statistics \u0026 Probability","Uncategorized","Tools"],"sub_categories":["NLP","Tools","Others","Semi-supervised Learning","Statistical Toolkit","网络服务_其他","General-Purpose Machine Learning","Uncategorized","Probabilistic programming framework"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgmpy%2Fpgmpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgmpy%2Fpgmpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgmpy%2Fpgmpy/lists"}