AGENT SKILL

learning-structure-and-parameters

Guide pgmpy causal discovery, CI tests, structure scores, expert knowledge, and parameter estimation from data.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
learning-structure-and-parameters
license
MIT
metadata
{ "disco-role": "operating" }
description
Guide pgmpy causal discovery, CI tests, structure scores, expert knowledge, and parameter estimation from data.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Learning Structure and Parameters

Use this sub-skill when the task is to learn graph structure or fit parameters from tabular data with pgmpy's canonical learning APIs. It covers causal/structure discovery, conditional-independence tests, structure scores, expert-knowledge constraints, and parameter estimators.

Own and reroute

Own these workflows:

  • Structure and causal discovery through pgmpy.causal_discovery: PC, HillClimbSearch, GES, ChowLiu, TAN, SP, TOPIC, ANM, IGCI, ExpertKnowledge, and optional expert/LLM-in-the-loop estimators.
  • Conditional-independence test selection through pgmpy.ci_tests.
  • Score-based structure learning through pgmpy.structure_score.
  • Parameter fitting through pgmpy.parameter_estimator: DiscreteMLE, DiscreteBayesianEstimator, DiscreteEM, and LinearGaussianMLE.

Reroute these requests:

  • Manual graph/model object construction, CPD authoring, factor objects, and model validation details -> modeling-and-factors.
  • Dataset registries, benchmark loading, metrics, and graph-evaluation reports -> data-io-and-evaluation.
  • Causal identification, adjustment/frontdoor sets, treatment-effect estimation, and do-effect prediction -> causal-identification-and-effects.

Canonical stance

Prefer the newer canonical packages over legacy pgmpy.estimators examples:

  1. Instantiate a discovery estimator from pgmpy.causal_discovery.
  2. Call fit(data).
  3. Read learned results from causal_graph_ and adjacency_matrix_.
  4. If parameters are needed, build or reuse the appropriate model family and call model.fit(data, estimator=...) with an initialized estimator from pgmpy.parameter_estimator.

Only use legacy pgmpy.estimators when the requested class has no canonical replacement or when reproducing an old API-specific workflow is explicitly required.

First actions for an agent

  1. Identify the data type and target model family before choosing a method: discrete, continuous/Gaussian, mixed conditional-Gaussian, tree/classifier, or bivariate direction.
  2. Read references/discovery-and-learning-api.md for imports, score names, CI-test names, and estimator contracts.
  3. Read references/workflows.md for recipes that combine discovery, expert knowledge, and parameter fitting.
  4. If the user reports errors or confusing output, read references/troubleshooting.md before changing code.
  5. For a no-network local smoke check, run scripts/learn_structure_smoke.py with the Python environment where pgmpy is installed.

Minimal working pattern

from pgmpy.causal_discovery import HillClimbSearch
from pgmpy.models import DiscreteBayesianNetwork
from pgmpy.parameter_estimator import DiscreteBayesianEstimator

est = HillClimbSearch(scoring_method="bic-d", return_type="dag", show_progress=False).fit(data)
model = DiscreteBayesianNetwork(est.causal_graph_.edges())
model.add_nodes_from(data.columns)
model.fit(data, estimator=DiscreteBayesianEstimator(prior_type="BDeu", equivalent_sample_size=5))

Keep show_progress=False in automated smoke tests and small examples unless the user specifically wants progress bars.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351