Skip to main content

Python library offering conventional anonymization techniques, utility metrics, and verification methods.

Installation

You can install the package via the command line:

pip install anonymity-api

Package Description

The package is divided into three different modules, as mentioned previously:

  • anonymity
  • utility
  • verify

Anonymity

This module contains the functions to anonymize data.

The conventional anonymization functions available are:

  • k-anonymity
  • distinct l-diversity
  • entropy l-diversity
  • recursive (c,l)-diversity
  • t-closeness

Another available function is the suggestion function that, given a dataset and its characteristics (list with quasi-identifiers and sensitive attributes), suggests an anonymization to use, returning an anonymized dataset without choosing a technique. This is helpful for users who may not know how to anonymize data or aren't familiar with it.

We also offer Workload-Aware anonymization techniques. These take the usual anonymization parameters also present in the conventional anonymization techniques but, in addition to that, the user can give a query representing to work to be done on the dataset. This ensures higher utility over the tasks to be done.

Technique Query
Simple query (quasi-identifier (operation) value )
Keeping correlation corr( quasi-identifier, sensitive-attribute )
Grouping group( quasi-identifier, value )

*operation can be: >, >=, =, < or <=

Utility

The utility module offers some utility techniques and a function that given an anonymized dataset, replaces the interval on the quasi-identifiers with a value comprehended in it.

The utility metrics available are:

  • Discernibility Metric
  • Average Equivalence Class Size Metric
  • Normalized Certainty Penalty

Verifier

This module given an anonymized dataset offers funtions for each of the conventional techniques in the Anonymization module.

These functions will say which parameter was used to anonymize the dataset. For instance, it would give the K for k-anonymity, l for distinct l-diversity, and so forth.

Anonymization Example

x y z
1 4 7
2 5 3
6 1 6
4 2 2

To anonymize the dataset above through k-anonymity, the following code would be valid:

import pandas as pd # necessary to create a dataframe
from anonymity_api import anonymity

# read the csv with data into a pandas dataframe
dataframe = pd.read_csv("data.csv") 

# We are anonymizing with k-anonymity, passing "x", and "y" as quasi-identifiers and "z" as a sensitive attribute
# And a value for k = 2
anonymized_data = anonymity.k_anonymity(data = dataframe, quasi_idents = ["x", "y"], k = 2, idents = ["z"])

The resulting dataset from this anonymization would be:

x y
1 - 2 4 - 5
1 - 2 4 - 5
4 - 6 1 - 2
4 - 6 1 - 2

For each tuple, there is at least one other tuple with the same values complying with our k of 2. The sensitive attribute z was removed.

Metadata

Release files for anonymity-api 1.1.1

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

Source distribution (sdist)

Source distribution for anonymity-api 1.1.1
File Size Uploaded
anonymity_api-1.1.1.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anonymity-api 1.1.1
File Interpreter ABI Platform
anonymity_api-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.8 kB

Release files / anonymity_api-1.1.1.tar.gz

Download URL anonymity_api-1.1.1.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fadc076af6b9b0ed561308193512b0181369a11c5429d015e5d5be0c56edaa54
BLAKE2b-256 checksum
How to use checksums
10ab9c7fdf5d59caf7bdbc799791732279385c3b8ab3453999c3e4e08c484795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.18

Release files / anonymity_api-1.1.1-py3-none-any.whl

Download URL anonymity_api-1.1.1-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bdb6c8935087281e66507158384b1dd5ebe683adc72cc8c16e778062c6e0daa
BLAKE2b-256 checksum
How to use checksums
f9a625391b1beb43bb6c253e51858c24d0ce20645b83fa13175028a4da528968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.18

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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