技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
pgmpy【数据与研究】Route pgmpy causal and probabilistic graphical-model tasks to focused modeling, learning, inference, causal, data I/O, and extension workflows.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this repo skill when the task names pgmpy or asks for Python workflows around causal graphs, Bayesian networks, Markov networks, conditional probability distributions, structure learning, probabilistic inference, causal identification/effect estimation, example graphical models, model file formats, or pgmpy extension work.
pgmpy is a Python package for causal and probabilistic reasoning with graphical models. It provides graph/model classes, CPDs and factors, causal discovery, parameter estimation, inference, sampling/simulation, causal identification and prediction, datasets/example models, metrics, and read/write utilities.
pip install pgmpy or conda install conda-forge::pgmpy.pip install -e .[tests] and focused pytest targets. Do not commit or push from an agent session.pgmpy[torch] for FunctionalBayesianNetwork/FunctionalCPD; pgmpy[optional] for plotting, xgboost, and LLM-assisted discovery dependencies. Provider credentials/network are still separate requirements.python scripts/check_pgmpy_environment.py --json from the skill root. Add --check-optional only when optional imports matter.references/repo-provenance.md before refreshing this skill for a changed checkout.references/package-map.md when choosing between canonical modules, legacy compatibility imports, optional extras, and public entry points.references/troubleshooting.md for cross-cutting install/import, optional dependency, state-name, network/cache, and package-version issues before diving into a sub-skill.| User task | Read |
|---|---|
Build a DAG, PDAG, ADMG, MAG, BN, DBN, Markov network, factor graph, CPD, or factor; debug check_model() or CPD shapes. | modeling-and-factors |
| Learn graph structure, choose PC/GES/HillClimb/Chow-Liu/TAN, select CI tests or scores, use expert knowledge, or fit CPDs from data. | learning-structure-and-parameters |
| Query posterior probabilities, run MAP, use Variable Elimination or Belief Propagation, sample/simulate from a fitted model, or work with DBN inference. | inference-sampling-and-simulation |
Identify adjustment/frontdoor sets, use CausalInference.query(..., do=...), estimate ATE, or use causal prediction regressors. | causal-identification-and-effects |
| Load/list built-in datasets or example models, save/load BIF/XMLBIF/NET/UAI/XDSL files, or compute graph/data evaluation metrics. | data-io-and-evaluation |
| Add a new causal discovery algorithm, CI test, score, metric, dataset, or example model to a pgmpy checkout. | extending-pgmpy |
modeling-and-factors; do not force a Bayesian-network model.learning-structure-and-parameters, then back to modeling-and-factors only for model-family construction details.P(Y | X=x), posterior marginals, MAP, or sampling under evidence, route to inference-sampling-and-simulation. If they ask for do(X=x), ATE, adjustment, frontdoor, instruments, or treatment effects, route to causal-identification-and-effects.bnlearn/alarm, a dataset name, or a .bif/.uai/.xmlbif file, route first to data-io-and-evaluation, then to the workflow that consumes the loaded object.pgmpy.causal_discovery, pgmpy.parameter_estimator, pgmpy.structure_score, pgmpy.ci_tests, pgmpy.metrics, pgmpy.datasets, and pgmpy.example_models. Treat pgmpy.estimators as a legacy compatibility surface unless the task is explicitly maintaining backwards compatibility.BayesianNetwork and MarkovNetwork are deprecated aliases for DiscreteBayesianNetwork and DiscreteMarkovNetwork.fit(...); fitted discovery results are typically available as causal_graph_ and adjacency_matrix_.check_model() before inference, simulation, serialization, or causal queries on parameterized models.show_progress=False in automated examples/tests unless progress bars are explicitly useful.For a quick installed-package check:
python scripts/check_pgmpy_environment.py --json
For workflow-specific checks, use the nearest bundled script:
modeling-and-factors/scripts/check_modeling_smoke.pylearning-structure-and-parameters/scripts/learn_structure_smoke.pyinference-sampling-and-simulation/scripts/inference_smoke.pycausal-identification-and-effects/scripts/causal_effect_smoke.pydata-io-and-evaluation/scripts/data_io_smoke.pyextending-pgmpy/scripts/extension_template_check.pyThese scripts are deterministic, no-network by default, and do not require the original repository checkout except extension_template_check.py, which is intentionally a checkout-maintenance helper and requires --repo when run away from the checkout.