簡體   English   中英

Python記錄聯動多核

[英]Python Record Linkage Multiple Cores

有沒有人有使用記錄鏈接工具包和超大數據集的經驗? 我有幾個問題。 最終,我需要將它部署到 EC2 實例,但現在,我正試圖弄清楚如何利用並行處理 - 我想在 EC2 上做同樣的事情。

指定核心數 (njobs) 時,代碼實際上運行速度比我不指定多個核心時要慢得多。

compare_dupes = rl.Compare(n_jobs=12)

與此相關 - 我正在處理一個包含 1200 萬條需要重復數據刪除的客戶記錄的記錄集。 目前我正在阻止名字、姓氏和 zip 代碼。

但是,潛在記錄對索引的數量仍然很大,導致 memory 故障。 我試過 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 萬時 - 甚至索引也無法放入 memory。

感謝您的支持!

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM