如何在给定相似度矩阵的情况下找到数据点之间的最佳匹配?
我陷入了一个非常简单的问题,但我越尝试解决它,它就变得越困难。或者也许没有比 O(N^2) 更好的解决方案了。问题很简单。我在第一组中有 N 个数据点,在第二组中有 M 个数据点。我有一个 NxM 相似度矩阵 A,这样 A[i, j] (范围在 0 和 1 之间)给出 Ni 和 Mj 数据点相似度的分数。
我想找出第一盘中的哪些得分与第二盘中的得分最好匹配。即输出是包含 N 个元素的列表,每个元素对应于它们最匹配的 M 组的唯一索引。
我正在使用numpy。我在第二个轴上对矩阵进行排序,但问题是 argsort 不会给我独特的索引。有了索引逻辑,它就变得非常混乱。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
np.argmax(A, axis=1)
完全符合您的描述(假设 1 表示最相似)。np.argmax(A, axis=1)
does exactly what you describe (assuming that 1 means most similar).