htfa.synthetic.match_factors

htfa.synthetic.match_factors(true_centers, est_centers)[source]

Match estimated factors to true ones with the Hungarian algorithm.

Parameters:
true_centersndarray, shape (K, D)

Ground-truth centers.

est_centersndarray, shape (K, D)

Estimated centers, in arbitrary order.

Returns:
permndarray of int, shape (K,)

Permutation such that est_centers[perm][k] corresponds to true_centers[k] (minimum total squared Euclidean distance).

Examples

>>> import numpy as np
>>> from htfa.synthetic import match_factors
>>> true = np.array([[0.0, 0.0], [5.0, 5.0]])
>>> est = np.array([[5.1, 4.9], [0.1, -0.1]])
>>> match_factors(true, est)
array([1, 0])