使用Jaccard索引找到所需技能和老师之间的最佳匹配
我有一组他们想要学习的技能的学生,并设有一系列他们准备教授的技能的老师。
基于此信息,我有以下给出的表。一个是给学生的,一个适合老师。 '1'代表学生愿意学习的技能,老师愿意教书。 '0'意味着相反。
| Students | Skill 1 | Skill 2 | Skill 3 | Skill 4 | Skill 5 |
|------------|-----------|---- ------|----------|----------|-----------|
| A | 1 | 0 | 0 | 1 | 0 |
| B | 1 | 1 | 0 | 0 | 1 |
| C | 0 | 0 | 1 | 1 | 0 |
| D | 1 | 1 | 0 | 1 | 1 |
| E | 0 | 1 | 1 | 0 | 1 |
| Teachers | Skill 1 | Skill 2 | Skill 3 | Skill 4 | Skill 5 |
|------------|-----------|---- ------|----------|----------|-----------|
| F | 1 | 1 | 1 | 1 | 1 |
| G | 0 | 1 | 0 | 0 | 0 |
| H | 0 | 0 | 1 | 1 | 1 |
| I | 1 | 1 | 0 | 0 | 0 |
| J | 0 | 0 | 1 | 0 | 1 |
我试图将老师与适当的学生相匹配,我可以看到的一个建议是使用jaccard索引。但是,我不确定jaccard索引在二进制数据上是否正常工作。
我试图根据以下的小数据集使用它,但我没有得到正确的结果。
import numpy as np
a = [0, 1, 1, 0, 1, 0, 0]
b = [0, 1, 1, 0, 1, 0, 0]
#define Jaccard Similarity function
def jaccard(list1, list2):
intersection = len(list(set(list1).intersection(list2)))
union = (len(list1) + len(list2)) - intersection
return float(intersection) / union
#find Jaccard Similarity between the two sets
jaccard(a, b)
即使二进制列表完全相同,0.16666也是输出。
在这种情况下,如何正确使用Jaccard索引或其他任何方式将老师与学生匹配的建议有什么建议?谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您想使用
第一步是计算jaccard索引的矩阵:
然后,我们可以解决 :
另外,如果您只想为每个学生提供最好的老师,即使这意味着有可能没有学生和其他学生的老师,请使用
idxmax
:If I understand correctly, you want to compute the maximum skill overlap using the Jaccard index and assign the "best" teacher to each student.
The first step is to compute a matrix of Jaccard indices:
Then, we can solve the assignment problem using
scipy.optimize.linear_sum_assignment
:Alternatively, if you just want the best teacher for each student, even if this means potentially having teachers without students and others with many students, use
idxmax
: