API reference

andrey.metrics.confounder_pair_scores#

andrey.metrics.confounder_pair_scores(estimated, true)[source]#

Precision/recall/f1 of bidirected (<->) pairs – the latent-confounder signals of a PAG.

Assumes both graphs speak the same PAG vocabulary (a latent confounder shows as a bidirected edge). Scoring a PAG estimate against a plain true DAG that has no bidirected edges reports the class mismatch as low recall, not a method error.

Return type:

dict[str, float]

Examples

>>> from andrey.core import GraphStructure
>>> import numpy as np
>>> g = GraphStructure.from_numpy(np.array([[0, 2], [2, 0]], dtype=np.int8), kind="pag")
>>> confounder_pair_scores(g, g)["precision"]
1.0