'How to find most optimal match between data points given the similarity matrix?
I am stuck on a very simple problem but more I try to solve it the harder it becomes. Or maybe there is no better solution than O(N^2). The problem is simple. I have N data points in first set and M data points in second. I have a NxM similarity matrix A such that A[i, j] (range is between 0 and 1) gives score about similarity of Ni and Mj data-points.
I want to find out which the points from first set match the best in the second. i.e the output is list with N elements each one corresponding to unique indices of M set which they match the most.
I am using numpy. I sort matrix on second axis but the issue is argsort will not give me unqiue indices. And with indices logic it becomes really confusing.
Solution 1:[1]
np.argmax(A, axis=1) does exactly what you describe (assuming that 1 means most similar).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | yut23 |
