API reference

andrey.metrics.temporal_scores#

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

Per-lag and summary scores for a temporal structure.

Returns per_lag (each lag’s precision/recall/f1/shd), a contemporaneous block when the estimate carries lag-0, an aggregate lagged block over lags >= 1, a summary graph collapsing every scored lag (self-loops excluded so diagonals do not inflate it), and coefficient_mae_per_lag when both structures carry lag weights.

Raises NotImplementedError for a time-carrying structure (n_times > 0): the (time, lag) axis has no metric yet, and scoring only the final-occasion projection would silently miss per-occasion differences.

Return type:

dict[str, object]

Examples

>>> import numpy as np
>>> from andrey.core import GraphStructure, TemporalStructure
>>> g = GraphStructure.from_numpy(np.array([[0, 1], [2, 0]], dtype=np.int8), kind="dag")
>>> t = TemporalStructure.from_lag_graphs([g])
>>> temporal_scores(t, t)["summary"]["f1"]
1.0