技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
data-io-and-evaluation【数据与研究】Guide pgmpy datasets, example models, model I/O formats, and evaluation metrics.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when a task asks to discover or load pgmpy built-in datasets or example models, validate local data artifacts, read or write model files, or evaluate learned structures/models with pgmpy metrics.
Do not use this sub-skill to choose or run learning algorithms, construct new
models/CPDs, or perform inference on a loaded model. Route structure/parameter
learning to learning-structure-and-parameters, graph/CPD construction to
modeling-and-factors, and posterior queries/simulation on loaded models to
inference-sampling-and-simulation.
list_datasets(...) and list_models(...) inspect registries and should
not fetch data.load_dataset(...) and load_model(...) may read the local Hugging Face
cache or download public assets when the cache is missing. Keep network
use explicit and optional.model.save(...) and DiscreteBayesianNetwork.load(...)
for common discrete-BN files: BIF, UAI, XMLBIF, XDSL, and NET.pgmpy.readwrite reader/writer classes for format-specific options,
strings, properties, XBN, PomdpX, or round-value control.LinearGaussianBayesianNetwork.save/load for its JSON schema.SHD, AdjacencyConfusionMatrix, or
OrientationConfusionMatrix after aligning node sets.CorrelationScore, ImpliedCIs,
FisherC, or StructureScore with a data frame whose columns cover graph
nodes.| Need | Primary pgmpy entry point | Notes |
|---|---|---|
| List dataset names by tags | pgmpy.datasets.list_datasets(**filters) | Local registry lookup. Common filters include is_discrete, is_continuous, has_ground_truth, n_samples, and n_variables. |
| Load a built-in dataset | pgmpy.datasets.load_dataset(name, n_samples=None, seed=None, **sim_kwargs) | Returns a Dataset with data, ground_truth, expert_knowledge, and tags; may require cache/network except for purely simulated assets. |
| List example model names by tags | pgmpy.example_models.list_models(**filters) | Local registry lookup. Filters include is_parameterized, is_discrete, is_continuous, n_nodes, and n_edges. |
| Load an example model | pgmpy.example_models.load_model(name) | Returns a DAG, DiscreteBayesianNetwork, LinearGaussianBayesianNetwork, or optional functional model family; may require cache/network. |
| Persist a discrete BN | model.save(path, filetype=...) and DiscreteBayesianNetwork.load(path, filetype=...) | Supports BIF, UAI, XMLBIF, XDSL, and NET through model-level helpers. |
| Format-specific parsing/writing | pgmpy.readwrite.*Reader / *Writer | Use for BIF, XMLBIF, NET, UAI, XDSL, XBN, and PomdpX options or string-based reads. |
| Persist a linear Gaussian BN | LinearGaussianBayesianNetwork.save(path) and .load(path) | JSON file/object with nodes, arcs, and cpds; see the bundled reference for schema notes. |
| Supervised graph comparison | SHD, AdjacencyConfusionMatrix, OrientationConfusionMatrix | Graphs must have identical node sets. Orientation confusion supports DAGs only. |
| Unsupervised graph/data evaluation | CorrelationScore, ImpliedCIs, FisherC, StructureScore | Requires a pandas data frame with columns for every graph node. |
from pgmpy.base import DAG
from pgmpy.metrics import SHD
true_graph = DAG([("A", "B"), ("B", "C")])
est_graph = DAG([("B", "A"), ("B", "C")])
# Supervised metrics require identical node sets, including isolated nodes.
est_graph.add_nodes_from(true_graph.nodes())
print(SHD()(true_causal_graph=true_graph, est_causal_graph=est_graph))
If that fails, inspect the exact graph node sets before changing the metric. Most metric errors come from missing/extra nodes, using a PDAG with a DAG-only metric, or passing data whose columns do not cover the graph variables.