Skip to main content
https://raw.githubusercontent.com/IFCA-Advanced-Computing/pycanon/main/images/pycanon_logo.png

License Codecov DOI Version Downloads Documentation Status Release PyPI Pipeline Status Coverage Python

pyCANON is a Python library and CLI to assess the values of the parameters associated with the most common privacy-preserving techniques via anonymization.

Authors: Judith Sáinz-Pardo Díaz and Álvaro López García (IFCA - CSIC).

Installation

We recommend to use Python3 with virtualenv:

virtualenv .venv -p python3
source .venv/bin/activate

Then run the following command to install the library and all its requirements:

pip install pycanon

If you also want to install the functionality that allows to generate PDF files for the reports, install as follows

pip install pycanon[PDF]

Documentation

The pyCANON documentation is hosted on Read the Docs.

Getting started

Example using the adult dataset:

import pandas as pd
from pycanon import anonymity, report

FILE_NAME = "adult.csv"
QI = ["age", "education", "occupation", "relationship", "sex", "native-country"]
SA = ["salary-class"]
DATA = pd.read_csv(FILE_NAME)

# Calculate k for k-anonymity:
k = anonymity.k_anonymity(DATA, QI)

# Print the anonymity report:
report.print_report(DATA, QI, SA)

Description

pyCANON allows to check if the following privacy-preserving techniques are verified and the value of the parameters associated with each of them.

Technique

pyCANON function

Parameters

Notes

k-anonymity

k_anonymity

k: int

(α, k)-anonymity

alpha_k_anonymity

α: float k:int

ℓ-diversity

l_diversity

ℓ: int

Entropy ℓ-diversity

entropy_l_diversity

ℓ: int

Recursive (c,ℓ)-diversity

recursive_c_l_diversity

c: int ℓ: int

Not calculated if ℓ=1

Basic β-likeness

basic_beta_likeness

β: float

Enhanced β-likeness

enhanced_beta_likeness

β: float

t-closeness

t_closeness

t: float

For numerical attributes the definition of the EMD (one-dimensional Earth Mover’s Distance) is used. For categorical attributes, the metric “Equal Distance” is used.

δ-disclosure privacy

delta_disclosure

δ: float

More information can be found in this paper.

In addition, a report can be obtained including information on the equivalence clases and the usefulness of the data. In particular, for the latter the following three classically used metrics are implemented (as defined in the documentation):

  • average equivalence class size

  • classification metric

  • discernability metric

Citation

If you are using pyCANON you can cite it as follows:

@article{sainzpardo2022pycanon,

title={A Python library to check the level of anonymity of a dataset}, author={Sáinz-Pardo Díaz, Judith and López García, Álvaro}, journal={Scientific Data}, volume={9}, number={1}, pages={785}, year={2022}, publisher={Nature Publishing Group UK London}}

Acknowledgments

The authors would like to thank the funding through the European Union - NextGenerationEU (Regulation EU 2020/2094), through CSIC’s Global Health Platform (PTI+ Salud Global) and the support from the projects AI4EOSC “Artificial Intelligence for the European Open Science Cloud” (funded by the European Union’s Horizon Europe research and innovation programme under grant agreement number 101058593) and EOSC SIESTA (funded by European Union’s Horizon Europe research and innovation programme under grant agreement number 101131957).

Metadata

Release files for pycanon 1.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycanon 1.3.7
File Size Uploaded Provenance Actions
pycanon-1.3.7.tar.gz 19.2 kB Without provenance Details for pycanon-1.3.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycanon 1.3.7
File Interpreter ABI Platform Actions
pycanon-1.3.7-py3-none-any.whl Python 3 none any Details for pycanon-1.3.7-py3-none-any.whl

Total release size: 55.2 kB

Release files / pycanon-1.3.7.tar.gz

Download URL pycanon-1.3.7.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6a93e29794b5f15998c3d254a8ab3fa6fb56b2167376c1699f41f82db10d6683
BLAKE2b-256 checksum
How to use checksums
a07648aa55e198c4281ce3dcd75acd0502bd53ba373098bfb6acf3767a2f6ab3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Release files / pycanon-1.3.7-py3-none-any.whl

Download URL pycanon-1.3.7-py3-none-any.whl
Size 36.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
059551317534cbe719435c718f48d3fa3a1f46767ce6aa420067d7e26c91158f
BLAKE2b-256 checksum
How to use checksums
277e2aeed7d93d603e3790df30f20b85e008a58a25adf4960e006342136aadc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for pycanon 1.3.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page