otlingam.utils.f1_score

f1_score(true_adjacency_matrix, pred_adjacency_matrix)[source]

Computes the directed-edge F1 score between two adjacency matrices.

The adjacency matrices are binarized by treating nonzero entries as edges. Diagonal entries are ignored, and directed edges are compared according to the LiNGAM convention, where entry (j, k) represents the edge \(k \to j\).

Parameters:
  • true_adjacency_matrix (np.typing.ArrayLike) – Ground-truth weighted adjacency matrix.

  • pred_adjacency_matrix (np.typing.ArrayLike) – Estimated weighted adjacency matrix.

Returns:

Directed-edge F1 score.

Return type:

float

Raises:

ValueError – If either matrix is not square or the shapes differ.