Skip to main content

pyCANON: A Python library to check the level of anonymity of a dataset.

Project description

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

License DOI PyPI Downloads Documentation Status Pipeline Status

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{'a}inz-Pardo D{'i}az, Judith and L{'o}pez Garc{'i}a, {'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).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycanon-1.2.1.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycanon-1.2.1-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

Details for the file pycanon-1.2.1.tar.gz.

File metadata

  • Download URL: pycanon-1.2.1.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pycanon-1.2.1.tar.gz
Algorithm Hash digest
SHA256 702cc51651d68275add6cb15317ce5fa444e72f67a705d4fa54d6b8cb609e9f0
MD5 e5e02670fce6a526182bacb711e975e8
BLAKE2b-256 cfb77cf682c0f99f990a770f39598eb9e1c9570dc5d1c25195d5c7159cb02e7d

See more details on using hashes here.

File details

Details for the file pycanon-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: pycanon-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 36.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pycanon-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 787078c13d5f73c97165f312ef9e62c005cff9be30f3afe8064e6296bf323308
MD5 625faadb1a926b3c6f31a89b06be0f71
BLAKE2b-256 4be071b9c2317902e925be64f963f8f6154f6d88fb1cc2322f85302e1345b325

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page