列表比较
我想计算两个列表之间的相似度百分比作为示例,如果我有两个描述图书属性的列表 list1(作者、品牌、isbn、类别、数量) list2(作者、价格、品牌) 我看到这个函数相似度= n/m,其中n是匹配概念的数量,m是两个列表中较小的基数我不知道它是否正确我看到m必须是具有更多概念的列表你同意我吗??
i want to calculate the percent of similarity between two lists as an example if i have two list that describe book attribute list1(author, brand , isbn, category, amount) list2(author , price , brand)
i saw this function similarity= n/m where n is the number of matched concepts and m is the smaller cardinality of two lists i dont know if it is correct i see that m must be the list with more number of concepts do you agree me??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Python 标准库有一个名为
difflib.SequenceMatcher
的类,它可以计算任意两个列表的相似度。The Python standard library has a class called
difflib.SequenceMatcher
that can compute this degree of similarity for any two lists.