【问题标题】:Python Record Linkage Multiple CoresPython记录联动多核
【发布时间】:2020-09-20 09:28:15
【问题描述】:

有人有使用记录链接工具包处理超大型数据集的经验吗?我有几个问题。最终,我需要将它部署到 EC2 实例,但现在,我正试图弄清楚如何利用并行处理 - 我想在 EC2 上做同样的事情。

当指定核心数 (njobs) 时,代码实际上比我不指定多个核心时运行得慢得多。

compare_dupes = rl.Compare(n_jobs=12)

与此相关 - 我正在处理一个包含 1200 万条需要重复数据删除的客户记录的记录集。目前我正在阻止名字、姓氏和邮政编码。

但是,潜在的记录对索引的数量仍然很大,以至于导致内存故障。我试过 Dask - 没有运气。我不确定还能尝试什么。有人有建议吗?我的代码如下所示:

# this section creates a huge multi-index, which causes memory failures
dupe_indexer = rl.Index()
dupe_indexer.block(['first_name_clean','last_name_clean','zip_clean'])
dupe_candidate_links = dupe_indexer.index(df_c)


# I can put n_jobs=12 (the number of cores) in the Compare function below, 
# but for some reason it actually performs worse

compare_dupes = rl.Compare()
compare_dupes.string('first_name_clean','first_name_clean', method='jarowinkler', threshold=0.85, label='first_name_cl')
compare_dupes.string('last_name_clean','last_name_clean', method='jarowinkler', threshold=0.85, label='last_name_cl')
compare_dupes.string('email', 'email', method='jarowinkler', threshold=0.90, label='email_cl')
compare_dupes.string('address_clean','address_clean', method='damerau_levenshtein', threshold=0.6, label='address_cl')

compare_dupes.string('zip_clean','zip_clean', method='jarowinkler',threshold=0.90, label='zip_cl'
dupe_features = compare_dupes.compute(dupe_candidate_links, df_c).reset_index()

我也试过“index_split”方法:

 s = rl.index_split(dupe_candidate_links, 100)
 for chunk in s:  

适用于小于 200 万的合理大小的数据集,但是当数据集的大小超过 5、8、10、15、2000 万时 - 甚至索引也无法放入内存。

感谢您的支持!

【问题讨论】:

  • 你的问题解决了吗,我也有同样的问题。

标签: python duplicates record-linkage


【解决方案1】:
indexer = recordlinkage.Index()
#Create indexing object
indexer = rl.SortedNeighbourhoodIndex(on='X')
# Create pandas MultiIndex containing candidate links
candidate_links = indexer.index(A, B)


%%time
comp = recordlinkage.Compare()
comp.string('X', 'X', method='jarowinkler', threshold=0.60)
mymatchestwonew = comp.compute(candidate_links, A, B)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多