Python Record Linkage Toolkit - Qgrams Error

Viewed 272

I have been following the example record linking code from the Python Record Linkage Toolkit package and it runs fine when using the 'jarowinkler' string matching method. However when running with method = "qgram" or "cosine" it throws a numpy error. Any thoughts on what may be causing the error?

File "C:\ProgramData\Anaconda3\lib\site-packages\recordlinkage\compare.py", line 153, in _compute_vectorized c = c.where((c < self.threshold) | (pandas.isnull(c)), other=1.0)

AttributeError: 'numpy.ndarray' object has no attribute 'where'

Code for Reference:

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', 'surname', method='qgram', threshold=0.1, label='surname')

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

for qgram and/or cosine method, remove the threshold value

Related