otlingam.utils.shd¶
- shd(true_adjacency_matrix, pred_adjacency_matrix)[source]¶
Computes structural Hamming distance between two directed graphs.
The adjacency matrices follow the LiNGAM convention, where entry (j, k) represents the directed edge \(k \to j\). A missing edge, an extra edge, and a reversed edge each contribute one unit to the structural Hamming distance.
- Parameters:
true_adjacency_matrix (np.typing.ArrayLike) – Ground-truth weighted adjacency matrix.
pred_adjacency_matrix (np.typing.ArrayLike) – Estimated weighted adjacency matrix.
- Returns:
Structural Hamming distance.
- Return type:
int
- Raises:
ValueError – If either matrix is not square or the shapes differ.