Anonymous linkage using cryptographic hashes and bloom filters
Project description
A Python (and optimised C++) implementation of anonymous linkage using cryptographic linkage keys as described by Rainer Schnell, Tobias Bachteler, and Jörg Reiher in A Novel Error-Tolerant Anonymous Linking Code.
anonlink computes similarity scores, and/or best guess matches between sets of cryptographic linkage keys (hashed entity records).
Use clkhash to create cryptographic linkage keys from personally identifiable data.
Installation
Install a precompiled wheel from PyPi:
pip install anonlink
Or (if your system has a C++ compiler) you can locally install from source:
pip install -r requirements.txt pip install -e .
Benchmark
You can run the benchmark with:
$ python -m anonlink.benchmark Anonlink benchmark -- see README for explanation ------------------------------------------------ Threshold: 0.5, All results returned Size 1 | Size 2 | Comparisons | Total Time (s) | Throughput | | (match %) | (comparisons / matching)| (1e6 cmp/s) -------+--------+------------------+-------------------------+------------- 1000 | 1000 | 1e6 (50.73%) | 0.762 (49.2% / 50.8%) | 2.669 2000 | 2000 | 4e6 (51.04%) | 3.696 (42.6% / 57.4%) | 2.540 3000 | 3000 | 9e6 (50.25%) | 8.121 (43.5% / 56.5%) | 2.548 4000 | 4000 | 16e6 (50.71%) | 15.560 (41.1% / 58.9%) | 2.504 Threshold: 0.5, Top 100 matches per record returned Size 1 | Size 2 | Comparisons | Total Time (s) | Throughput | | (match %) | (comparisons / matching)| (1e6 cmp/s) -------+--------+------------------+-------------------------+------------- 1000 | 1000 | 1e6 ( 6.86%) | 0.170 (85.9% / 14.1%) | 6.846 2000 | 2000 | 4e6 ( 3.22%) | 0.384 (82.9% / 17.1%) | 12.561 3000 | 3000 | 9e6 ( 2.09%) | 0.612 (81.6% / 18.4%) | 18.016 4000 | 4000 | 16e6 ( 1.52%) | 0.919 (78.7% / 21.3%) | 22.135 5000 | 5000 | 25e6 ( 1.18%) | 1.163 (80.8% / 19.2%) | 26.592 6000 | 6000 | 36e6 ( 0.97%) | 1.535 (75.4% / 24.6%) | 31.113 7000 | 7000 | 49e6 ( 0.82%) | 1.791 (80.6% / 19.4%) | 33.951 8000 | 8000 | 64e6 ( 0.71%) | 2.095 (81.5% / 18.5%) | 37.466 9000 | 9000 | 81e6 ( 0.63%) | 2.766 (72.5% / 27.5%) | 40.389 10000 | 10000 | 100e6 ( 0.56%) | 2.765 (81.7% / 18.3%) | 44.277 20000 | 20000 | 400e6 ( 0.27%) | 7.062 (86.2% / 13.8%) | 65.711 Threshold: 0.7, All results returned Size 1 | Size 2 | Comparisons | Total Time (s) | Throughput | | (match %) | (comparisons / matching)| (1e6 cmp/s) -------+--------+------------------+-------------------------+------------- 1000 | 1000 | 1e6 ( 0.01%) | 0.009 (99.0% / 1.0%) | 113.109 2000 | 2000 | 4e6 ( 0.01%) | 0.033 (98.7% / 1.3%) | 124.076 3000 | 3000 | 9e6 ( 0.01%) | 0.071 (99.1% / 0.9%) | 128.515 4000 | 4000 | 16e6 ( 0.01%) | 0.123 (99.0% / 1.0%) | 131.654 5000 | 5000 | 25e6 ( 0.01%) | 0.202 (99.1% / 0.9%) | 124.999 6000 | 6000 | 36e6 ( 0.01%) | 0.277 (99.0% / 1.0%) | 131.403 7000 | 7000 | 49e6 ( 0.01%) | 0.368 (98.9% / 1.1%) | 134.428 8000 | 8000 | 64e6 ( 0.01%) | 0.490 (99.0% / 1.0%) | 131.891 9000 | 9000 | 81e6 ( 0.01%) | 0.608 (99.0% / 1.0%) | 134.564 10000 | 10000 | 100e6 ( 0.01%) | 0.753 (99.0% / 1.0%) | 134.105 20000 | 20000 | 400e6 ( 0.01%) | 2.905 (98.8% / 1.2%) | 139.294 Threshold: 0.7, Top 100 matches per record returned Size 1 | Size 2 | Comparisons | Total Time (s) | Throughput | | (match %) | (comparisons / matching)| (1e6 cmp/s) -------+--------+------------------+-------------------------+------------- 1000 | 1000 | 1e6 ( 0.01%) | 0.009 (99.0% / 1.0%) | 111.640 2000 | 2000 | 4e6 ( 0.01%) | 0.033 (98.6% / 1.4%) | 122.060 3000 | 3000 | 9e6 ( 0.01%) | 0.074 (99.1% / 0.9%) | 123.237 4000 | 4000 | 16e6 ( 0.01%) | 0.124 (99.0% / 1.0%) | 130.204 5000 | 5000 | 25e6 ( 0.01%) | 0.208 (99.1% / 0.9%) | 121.351 6000 | 6000 | 36e6 ( 0.01%) | 0.275 (99.0% / 1.0%) | 132.186 7000 | 7000 | 49e6 ( 0.01%) | 0.373 (99.0% / 1.0%) | 132.650 8000 | 8000 | 64e6 ( 0.01%) | 0.496 (99.1% / 0.9%) | 130.125 9000 | 9000 | 81e6 ( 0.01%) | 0.614 (99.0% / 1.0%) | 133.216 10000 | 10000 | 100e6 ( 0.01%) | 0.775 (99.1% / 0.9%) | 130.230 20000 | 20000 | 400e6 ( 0.01%) | 2.939 (98.9% / 1.1%) | 137.574
The tables are interpreted as follows. Each table measures the throughput of the Dice coefficient comparison function. The four tables correspond to two different choices of “matching threshold” and “result limiting”.
These parameters have been chosen to characterise two different performance scenarios. Since the data used for comparisons is randomly generated, the first threshold value (0.5) will cause about 50% of the candidates to “match”, while the second threshold value (0.7) will cause ~0.01% of the candidates to match (these values are reported in the “match %” column). Where the table heading includes “All results returned”, all matches above the threshold are returned and passed to the solver. With the threshold of 0.5, the large number of matches means that much of the time is spent keeping the candidates in order. Next we limit the number of matches per record to the top 100 - which also must be above the threshold.
In the final two tables we use the threshold value of 0.7, this very effectively filters the number of candidate matches down. Here the throughput is determined primarily by the comparison code itself, adding the top 100 filter has no major impact.
Finally, the Total Time column includes indications as to the proportion of time spent calculating the (sparse) similarity matrix comparisons and the proportion of time spent matching in the greedy solver. This latter is determined by the size of the similarity matrix, which will be approximately #comparisons * match% / 100.
Tests
Run unit tests with pytest:
$ pytest ====================================== test session starts ====================================== platform linux -- Python 3.6.4, pytest-3.2.5, py-1.4.34, pluggy-0.4.0 rootdir: /home/hlaw/src/n1-anonlink, inifile: collected 71 items tests/test_benchmark.py ... tests/test_bloommatcher.py .............. tests/test_e2e.py .............ss.... tests/test_matcher.py ..x.....x......x....x.. tests/test_similarity.py ......... tests/test_util.py ... ======================== 65 passed, 2 skipped, 4 xfailed in 4.01 seconds ========================
To enable slightly larger tests add the following environment variables:
INCLUDE_10K
INCLUDE_100K
Limitations
The linkage process has order n^2 time complexity - although algorithms exist to significantly speed this up. Several possible speedups are described in Privacy Preserving Record Linkage with PPJoin.
Discussion
If you run into bugs, you can file them in our issue tracker on GitHub.
There is also an anonlink mailing list for development discussion and release announcements.
Wherever we interact, we strive to follow the Python Community Code of Conduct.
Citing
Anonlink is designed, developed and supported by CSIRO’s Data61. If you use any part of this library in your research, please cite it using the following BibTex entry:
@misc{Anonlink, author = {CSIRO's Data61}, title = {Anonlink Private Record Linkage System}, year = {2017}, publisher = {GitHub}, journal = {GitHub Repository}, howpublished = {\url{https://github.com/data61/anonlink}}, }
License
Copyright 2017 CSIRO (Data61)
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file anonlink-0.14.1.tar.gz
.
File metadata
- Download URL: anonlink-0.14.1.tar.gz
- Upload date:
- Size: 46.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33b573ecc211ebd05be0b3bb01ad97f86dd3473a3d32fe9ab925e39f035b6769 |
|
MD5 | e7f470aa01ed5ccb606cbf230020aba2 |
|
BLAKE2b-256 | 0ec058d9c51932483e83a4d14a30d985dc7007c0dd489941f1979293b7ff42d9 |
File details
Details for the file anonlink-0.14.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 182.0 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 102035de69a4b29b39914eff5291e44240218525a7bf1606337014b874c4d2b8 |
|
MD5 | c5e90906dab9f5a7d6b1d407bce53ca1 |
|
BLAKE2b-256 | 3249ce10a2291ab191c9e76002056eeb644c08443450b726ed0a80bb5e41925f |
File details
Details for the file anonlink-0.14.1-cp39-cp39-manylinux2010_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp39-cp39-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a811920c288b411cb3e40fddb4e72d8feb63bda3db9ace3823dd3b28c4a4b9c |
|
MD5 | 52e1b7003cf3cfb478d7473d21c901a7 |
|
BLAKE2b-256 | c2f3f78e01eed41bc56ce64eff8b567439aecf4a5dcd7b6494d9295364f4069d |
File details
Details for the file anonlink-0.14.1-cp39-cp39-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 215.2 kB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12c6ed7c49213915a4b747478049521e689d828f7375e008bab44b7f4b9beb42 |
|
MD5 | 7fd3c51be8c71f0581aa2e187c7f6163 |
|
BLAKE2b-256 | ac824c82b4fb42557d04985b7d5589d6d8929cc0621c40e1042ccdc58c419274 |
File details
Details for the file anonlink-0.14.1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 182.0 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3be8dda382b9689bb26fbbdf715ee5759e9418e160a669adba287389279d335 |
|
MD5 | 076d942f4a6822f33b93836b09f449df |
|
BLAKE2b-256 | 9ccf5d67083e5cf2e5150840ac305b798a076502dfbdd48e1c52b5eba83a866d |
File details
Details for the file anonlink-0.14.1-cp38-cp38-manylinux2010_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp38-cp38-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dfb6738820aeb36fe13de7b39c9bfc5b458306223436a5c7639eff1c72a12d8 |
|
MD5 | f7f32a5000997d03186d2b8f491815d4 |
|
BLAKE2b-256 | 44023bf9d4822901b34e3ae6871b4d2a40dc2c6211998c4319f5fa7bbbd45255 |
File details
Details for the file anonlink-0.14.1-cp38-cp38-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 210.9 kB
- Tags: CPython 3.8, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3fef51444cd3053b5fd32abec5f820dee68bbe3e207f8a9779966da122aee15 |
|
MD5 | 750c105f1d77aac6f74265aad9184eb9 |
|
BLAKE2b-256 | abdda5fc33b56cd18585c919d4c52f49f9a043db7786174c1679de4f802f10da |
File details
Details for the file anonlink-0.14.1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 180.5 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c5f36e5e8b883afa9b006dd69ac7b4feb404bce466fc9774e52af9f6a32a3a |
|
MD5 | 881235745a530c7c40a0e62c0045f2fb |
|
BLAKE2b-256 | fa065527bc971761e74c6b3b0b55c2269434f1066e27b944015168344ea5a7d3 |
File details
Details for the file anonlink-0.14.1-cp37-cp37m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp37-cp37m-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21c55d5ec411a84f6d9eaaa68fd7b3fc7d113883d2ef03d0c7c78f87aa6957ba |
|
MD5 | 39fb184ccb7b98281870ca03010f9a30 |
|
BLAKE2b-256 | 5e9b97ba7cdc7caa4eb71a3d321e59a77996b2e8a79707089c440ca5f5c231ef |
File details
Details for the file anonlink-0.14.1-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 211.2 kB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76fe77df049c6a884aa8a74aecccd1948c6a12ef1b81a534a0b148c368a76218 |
|
MD5 | d3be0731795f21e40ef2096901b6c60a |
|
BLAKE2b-256 | 568c95460f6a0aceee823a65aa0b7af40090f17035822c9cacc48a8446f6b3ea |
File details
Details for the file anonlink-0.14.1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 180.4 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 533f60cd130a682683c358c5bc1d92696128078a06b99eeff4234a99a381021a |
|
MD5 | 29943f6c7a03f8aa70a2b3d1ed5437a1 |
|
BLAKE2b-256 | bad04ac2a0baf803ad7094012830251ee7d2b858732978536391150faeff8e2a |
File details
Details for the file anonlink-0.14.1-cp36-cp36m-manylinux2010_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp36-cp36m-manylinux2010_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f244abdb79eedddcbf11968caed53b70384232429d61bd01b6a02935e58a33be |
|
MD5 | 3420791be82431f96eea89a2a40076b1 |
|
BLAKE2b-256 | a2862c6c7484fbe922b6ef83776d399ded975cf0acd4bbd9fdc785d5c0eb8044 |
File details
Details for the file anonlink-0.14.1-cp36-cp36m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: anonlink-0.14.1-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 211.1 kB
- Tags: CPython 3.6m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd480b105e2c69663c7e1fc3dba34eff117aa5a4b21c0066dfcb380b970635ff |
|
MD5 | 01c306e04bacd0af4068f69f60b8a05b |
|
BLAKE2b-256 | 4072522d615f086ab3ad5ef040bd72098d02eac2214a5a2a966e4802ad96ab6f |