andrey.metrics.shd#
- andrey.metrics.shd(estimated, true, *, endpoint_aware=False)[source]#
Structural Hamming distance between two graphs (lower is better;
shd(g, g) == 0).The default structural count charges one edit per unordered pair whose
(mark_i, mark_j)differs, so an inserted, deleted, or reversed edge each costs 1.endpoint_aware=Truesums the per-endpoint mark mismatches instead – the standard PAG distance, where a reversal or a deleted directed edge costs 2 and tail/arrow/circle are distinguished.- Return type:
Examples
>>> import numpy as np >>> shd(np.array([[0, 1], [0, 0]]), np.array([[0, 0], [1, 0]])) # 0->1 vs 1->0 1