【发布时间】:2018-06-11 13:37:48
【问题描述】:
我有一个大约 10 万个名字的列表。这些是人名、公司名称等。名称可以完全匹配,也可以在某些方面有所不同。我也有地址,但地址可能有误或可能不存在。我需要收集并计算每个名称以进行分析。这是一个示例集,
Bank America, N.A
BOA
Bank f Amerca
America Bank
Wells Fargo Bank
Wells Fargo
Wells Fargo, N.A
Fargo Bank
对于Bank of America,计数将是三个,因为America Bank 是不同的。对于Wells Fargo,计数将是三,因为Fargo Bank 是不同的。
编辑:
除了使用机器学习之外,另一种选择是使用模糊匹配。我查看了 difflib 和fuzzywuzzy 库,但问题是我没有参考列表;逻辑本身必须找出参考(这就是为什么我认为机器学习是答案)。
作为练习,这里是第二个数据示例,
John Smith - First instance found, therefore, this is labeled as ID 1
Chase Bank - First instance found, this is labeled as ID 2
John J. Smith - Similar to John Smith, therefore, this is labeled as ID 1
BOA - First instance found, this is labeled as ID 3
Bank of America - Not similar to BOA, therefore labeled as ID 4 (Technically this is BOA but the system will not know this at first)
BOA, N.A. - Similar to BOA, therefore labeled as ID 3
现在让我们以BOA 和Bank of America 为例。程序如何知道这些是相同的?它不会,所以我需要回来并指出BOA 和Bank of America 是相同的。如果我们走机器学习路线,我可以创建一个新字段并手动指示BOA 和Bank of America 相同,然后再次重试该过程以获得更好的结果。但是假设我们想走简单的路线而不是这样做,是否有 python 库可以帮助我?
比起实际的代码,我更需要一个好的起点。
【问题讨论】:
标签: python machine-learning scikit-learn