如何在给定相似度矩阵的情况下找到数据点之间的最佳匹配?

发布于 2025-01-12 04:55:51 字数 306 浏览 2 评论 0原文

我陷入了一个非常简单的问题,但我越尝试解决它,它就变得越困难。或者也许没有比 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后知后觉 2025-01-19 04:55:51

np.argmax(A, axis=1) 完全符合您的描述(假设 1 表示最相似)。

np.argmax(A, axis=1) does exactly what you describe (assuming that 1 means most similar).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文