andrey.metrics.score#
- andrey.metrics.score(output, truth)[source]#
Score an estimated result against ground truth with the family-appropriate metrics.
outputandtruthmay each be a StructureOutput, a Structure, or a raw adjacency, and must index the same variables in the same order (a label or node-count mismatch raises). A latent structure is scored on its clustering alone, since latent node indices are not aligned across the two graphs; CDNOD’s appended domain node and similar extra variables must be dropped by the caller first.- Returns:
A flat, JSON-safe dict whose
familynames the structures’ kind. Every metric whose inputs both structures carry is present; the rest are absent.Every graph:
skeleton_precision,skeleton_recall,skeleton_f1,arrowhead_precision,arrowhead_recall,arrowhead_f1, andshd.dagaddsmec_shdandmec_arrowhead_f1, scored through the CPDAGs for methods identified only up to their equivalence class, andorder_*andcoefficient_maewhen an ordering or weights are present.pagaddsshd_endpointandconfounder_precision,confounder_recall, andconfounder_f1.digraphkeeps the base metrics only: it has no CPDAG, and a 2-cycle claims no latent confounder. Comparing adigraphwith apagraises.latent:latent_cluster_ari,n_latents_estimated, andn_latents_true.temporal:per_lag,contemporaneous,lagged, andsummary, each nested, pluscoefficient_mae_per_lag.
- Return type:
Examples
>>> import numpy as np >>> score(np.array([[0, 1], [0, 0]]), np.array([[0, 1], [0, 0]]))["family"] 'dag'