precision = np.mean(dist.max(axis=0))
// Recall: how many of the intervals did we catch?
recall = np.mean(dist.max(axis=1))
// And the f-measure
f_measure = util.f_measure(precision, recall, beta=beta)
After Change
n_ref, n_est = len(reference_boundaries), len(estimated_boundaries)
skew_adjacency = np.zeros((n_ref + n_est, n_ref + n_est), dtype=np.int32)
window_match = np.abs(np.subtract.outer(reference_boundaries, estimated_boundaries)) <= window
window_match = window_match.astype(int)
// L. Lovasz On determinants, matchings and random algorithms.
// In L. Budach, editor, Fundamentals of Computation Theory, pages 565-574. Akademie-Verlag, 1979.
//
// If we build the skew-symmetric adjacency matrix
// D[i, n_ref+j] = 1 <=> ref[i] within window of est[j]
// D[n_ref + j, i] = -1 <=> same
//
// then rank(D) = 2 * maximum matching
//
skew_adjacency[:n_ref, n_ref:] = window_match
skew_adjacency[n_ref:, :n_ref] = -window_match.T
matching_size = np.linalg.matrix_rank(skew_adjacency) / 2.0
// Precision = |matching| / |// predictions|