跳转到主要内容

使用加密散列和布隆过滤器进行匿名链接

项目描述

https://dev.azure.com/data61/Anonlink/_apis/build/status/data61.anonlink?branchName=main https://github.com/data61/anonlink/actions/workflows/unittests.yml/badge.svg?branch=main https://codecov.io/gh/data61/anonlink/branch/main/graph/badge.svg?token=04DblXwUsT https://pepy.tech/badge/anonlink

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.

安装

从 PyPi 安装预编译的 wheel 文件

pip install anonlink

或者(如果您的系统有 C++ 编译器),您可以从源代码本地安装

pip install -r requirements.txt
pip install -e .

基准测试

您可以使用以下命令运行基准测试

$ 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

表格的解释如下。每个表格衡量 Dice 系数比较函数的吞吐量。四个表格对应两种不同的“匹配阈值”和“结果限制”选择。

这些参数被选择来表征两种不同的性能场景。由于用于比较的数据是随机生成的,第一个阈值值(0.5)将导致约 50% 的候选者“匹配”,而第二个阈值值(0.7)将导致 ~0.01% 的候选者匹配(这些值在“匹配 %”列中报告)。如果表头包括“返回所有结果”,则所有高于阈值的匹配都将返回并传递给求解器。在 0.5 的阈值下,大量的匹配意味着大部分时间都花在保持候选者顺序上。接下来我们限制每条记录的匹配数最多为 100 - 这也必须高于阈值。

在最后两个表格中,我们使用阈值值 0.7,这非常有效地过滤了候选匹配的数量。在这里,吞吐量主要取决于比较代码本身,添加前 100 个过滤器没有产生重大影响。

最后,总时间列包括关于计算(稀疏)相似性矩阵 比较 所花费时间比例以及花费在贪婪求解器中的 匹配 时间的指示。后者的确定由相似性矩阵的大小决定,这大约是 comparisons * match% / 100。

测试

使用 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 ========================

要启用稍大的测试,请添加以下环境变量

  • INCLUDE_10K

  • INCLUDE_100K

局限性

讨论

如果您遇到错误,可以在我们的 GitHub 问题跟踪器 中报告。

还有一个 anonlink 邮件列表 用于开发讨论和发布公告。

无论我们在哪里互动,我们都努力遵循 Python 社区行为准则

引用

Anonlink 是由 CSIRO 的 Data61 设计、开发和支持的。如果您在研究中使用了这个库的任何部分,请使用以下 BibTex 条目进行引用

@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}},
}

许可证

版权 2017 CSIRO (Data61)

根据 Apache License 2.0(“许可”)许可;除非遵守许可,否则您不得使用此文件。您可以在以下位置获得许可副本

https://apache.ac.cn/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则在许可证下分发的软件按照“现状”原则分发,不提供任何形式的明示或暗示保证。有关许可证的权限和限制的特定语言,请参阅许可证。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分发

anonlink-0.15.3.tar.gz (303.5 kB 查看哈希值)

上传时间

构建分发

anonlink-0.15.3-pp39-pypy39_pp73-win_amd64.whl (173.7 kB 查看哈希值)

上传时间 PyPy Windows x86-64

anonlink-0.15.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (236.0 kB 查看哈希值)

上传时间 PyPy manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (181.0 kB 查看哈希值)

上传时间 PyPy macOS 10.9+ x86-64

anonlink-0.15.3-pp38-pypy38_pp73-win_amd64.whl (173.7 kB 查看哈希值)

上传于 PyPy Windows x86-64

anonlink-0.15.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (236.1 kB 查看哈希值)

上传于 PyPy manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (181.3 kB 查看哈希值)

上传于 PyPy macOS 10.9+ x86-64

anonlink-0.15.3-pp37-pypy37_pp73-win_amd64.whl (173.7 kB 查看哈希值)

上传于 PyPy Windows x86-64

anonlink-0.15.3-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (236.4 kB 查看哈希值)

上传于 PyPy manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (181.3 kB 查看哈希值)

上传于 PyPy macOS 10.9+ x86-64

anonlink-0.15.3-cp311-cp311-win_amd64.whl (182.6 kB 查看哈希值)

上传于 CPython 3.11 Windows x86-64

anonlink-0.15.3-cp311-cp311-musllinux_1_1_x86_64.whl (1.8 MB 查看哈希值)

上传于 CPython 3.11 musllinux: musl 1.1+ x86-64

anonlink-0.15.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB 查看哈希值)

上传于 CPython 3.11 manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-cp311-cp311-macosx_11_0_arm64.whl (190.5 kB 查看哈希值)

上传于 CPython 3.11 macOS 11.0+ ARM64

anonlink-0.15.3-cp311-cp311-macosx_10_9_x86_64.whl (209.1 kB 查看哈希值)

上传于 CPython 3.11 macOS 10.9+ x86-64

anonlink-0.15.3-cp310-cp310-win_amd64.whl (184.0 kB 查看哈希值)

上传于 CPython 3.10 Windows x86-64

anonlink-0.15.3-cp310-cp310-musllinux_1_1_x86_64.whl (1.7 MB 查看哈希值)

上传于 CPython 3.10 musllinux: musl 1.1+ x86-64

anonlink-0.15.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB 查看哈希值)

上传于 CPython 3.10 manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-cp310-cp310-macosx_11_0_arm64.whl (193.6 kB 查看哈希值)

上传于 CPython 3.10 macOS 11.0+ ARM64

anonlink-0.15.3-cp310-cp310-macosx_10_9_x86_64.whl (212.2 kB 查看哈希值)

上传于 CPython 3.10 macOS 10.9+ x86-64

anonlink-0.15.3-cp39-cp39-win_amd64.whl (186.2 kB 查看哈希值)

上传于 CPython 3.9 Windows x86-64

anonlink-0.15.3-cp39-cp39-musllinux_1_1_x86_64.whl (1.8 MB 查看哈希值)

上传于 CPython 3.9 musllinux: musl 1.1+ x86-64

anonlink-0.15.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB 查看哈希值)

上传于 CPython 3.9 manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-cp39-cp39-macosx_11_0_arm64.whl (193.8 kB 查看哈希值)

上传于 CPython 3.9 macOS 11.0+ ARM64

anonlink-0.15.3-cp39-cp39-macosx_10_9_x86_64.whl (212.9 kB 查看哈希值)

上传于 CPython 3.9 macOS 10.9+ x86-64

anonlink-0.15.3-cp38-cp38-win_amd64.whl (186.0 kB 查看哈希值)

上传于 CPython 3.8 Windows x86-64

anonlink-0.15.3-cp38-cp38-musllinux_1_1_x86_64.whl (1.8 MB 查看哈希)

上传于 CPython 3.8 musllinux: musl 1.1+ x86-64

anonlink-0.15.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB 查看哈希)

上传于 CPython 3.8 manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-cp38-cp38-macosx_11_0_arm64.whl (190.4 kB 查看哈希)

上传于 CPython 3.8 macOS 11.0+ ARM64

anonlink-0.15.3-cp38-cp38-macosx_10_9_x86_64.whl (208.8 kB 查看哈希)

上传于 CPython 3.8 macOS 10.9+ x86-64

anonlink-0.15.3-cp37-cp37m-win_amd64.whl (184.4 kB 查看哈希)

上传于 CPython 3.7m Windows x86-64

anonlink-0.15.3-cp37-cp37m-musllinux_1_1_x86_64.whl (1.7 MB 查看哈希)

上传于 CPython 3.7m musllinux: musl 1.1+ x86-64

anonlink-0.15.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB 查看哈希)

上传于 CPython 3.7m manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-cp37-cp37m-macosx_10_9_x86_64.whl (209.4 kB 查看哈希)

上传于 CPython 3.7m macOS 10.9+ x86-64

anonlink-0.15.3-cp36-cp36m-win_amd64.whl (184.4 kB 查看哈希)

上传于 CPython 3.6m Windows x86-64

anonlink-0.15.3-cp36-cp36m-musllinux_1_1_x86_64.whl (1.7 MB 查看哈希)

上传于 CPython 3.6m musllinux: musl 1.1+ x86-64

anonlink-0.15.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB 查看哈希)

上传于 CPython 3.6m manylinux: glibc 2.17+ x86-64

anonlink-0.15.3-cp36-cp36m-macosx_10_9_x86_64.whl (209.2 kB 查看哈希值)

上传时间 CPython 3.6m macOS 10.9+ x86-64

支持者