Python 记录链接工具包 - Qgrams 错误

问题描述

我一直在关注 Python Record Linkage Toolkit 包中的示例记录链接代码,它在使用“jarowinkler”字符串匹配方法时运行良好。但是,当使用 method = "qgram" 或 "cosine" 运行时,它会抛出一个 numpy 错误。关于可能导致错误的原因有什么想法吗?

文件 "C:\ProgramData\Anaconda3\lib\site-packages\recordlinkage\compare.py",第 153 行,在 _compute_vectorized c = c.where((c

AttributeError: 'numpy.ndarray' 对象没有属性 'where'

参考代码

import recordlinkage
from recordlinkage.datasets import load_febrl1

##### Functions Correctly

dfA = load_febrl1()

# Indexation step
indexer = recordlinkage.Index()
indexer.block(left_on='given_name')
candidate_links = indexer.index(dfA)

compare_cl = recordlinkage.Compare()

compare_cl.string('surname','surname',method='jaro',threshold=0.1,label='surname')

features = compare_cl.compute(candidate_links,dfA)
matches = features[features.sum(axis=1) > 0]
print(len(matches))

##### Fails with:
#     AttributeError: 'numpy.ndarray' object has no attribute 'where'

dfA = load_febrl1()

# Indexation step
indexer = recordlinkage.Index()
indexer.block(left_on='given_name')
candidate_links = indexer.index(dfA)

compare_cl = recordlinkage.Compare()

compare_cl.string('surname',method='qgram',dfA)
matches = features[features.sum(axis=1) > 0]
print(len(matches))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)