match

Contents

match#

mofaflex.tl.match(reference, permutable, axis)#

Find optimal permutation and signs to match two tensors along specified axis.

Finds the permutation and sign of permutable along one axis to maximize correlation with reference. Useful for comparing ground truth factor scores/loadings with inferred values where factor order and sign is arbitrary.

Parameters:
Return type:

tuple[ndarray[tuple[Any, ...], dtype[int]], ndarray[tuple[Any, ...], dtype[int]], ndarray[tuple[Any, ...], dtype[ubyte]]]

Returns:

A tuple with optimal permutation indices and optimal signs (+1 or -1) for each permuted element.

Notes

  • Special handling for non-negative arrays

  • Uses linear sum assignment to find optimal matching