ANJANA is an open source framework for applying different anonymity techniques.
Project description
ANJANA
Anonymity as major assurance of personal data privacy
ANJANA is a Python library for anonymizing sensitive data.
The following anonymity techniques are implemented, based on the Python library pyCANON:
- k-anonymity.
- (α,k)-anonymity.
- ℓ-diversity.
- Entropy ℓ-diversity.
- Recursive (c,ℓ)-diversity.
- t-closeness.
- Basic β-likeness.
- Enhanced β-likeness.
- δ-disclosure privacy.
Getting started
For anonymizing your data you need to introduce:
- The pandas dataframe with the data to be anonymized. Each column can contain: indentifiers, quasi-indentifiers or sensitive attributes.
- The list with the names of the identifiers in the dataframe, in order to suppress them.
- The list with the names of the quasi-identifiers in the dataframe.
- The sentive attribute (only one) in case of applying other techniques than k-anonymity.
- The level of anonymity to be applied, e.g. k (for k-anonymity), ℓ (for ℓ-diversity), t (for t-closeness), β (for basic or enhanced β-likeness), etc.
- Maximum level of record suppression allowed (from 0 to 100).
- Dictionary containing one dictionary for each quasi-identifier with the hierarchies and the levels.
Example: apply k-anonymity, ℓ-diversity and t-closeness to the adult dataset with some predefined hierarchies:
import pandas as pd
import anjana
from anjana.anonymity import k_anonymity, l_diversity, t_closeness
# Read and process the data
data = pd.read_csv("adult.csv")
data.columns = data.columns.str.strip()
cols = [
"workclass",
"education",
"marital-status",
"occupation",
"sex",
"native-country",
]
for col in cols:
data[col] = data[col].str.strip()
# Define the identifiers, quasi-identifiers and the sensitive attribute
quasi_ident = [
"age",
"education",
"marital-status",
"occupation",
"sex",
"native-country",
]
ident = ["race"]
sens_att = "salary-class"
# Select the desired level of k, l and t
k = 10
l_div = 2
t = 0.5
# Select the suppression limit allowed
supp_level = 50
# Import the hierarquies for each quasi-identifier. Define a dictionary containing them
hierarchies = {
"age": dict(pd.read_csv("hierarchies/age.csv", header=None)),
"education": dict(pd.read_csv("hierarchies/education.csv", header=None)),
"marital-status": dict(pd.read_csv("hierarchies/marital.csv", header=None)),
"occupation": dict(pd.read_csv("hierarchies/occupation.csv", header=None)),
"sex": dict(pd.read_csv("hierarchies/sex.csv", header=None)),
"native-country": dict(pd.read_csv("hierarchies/country.csv", header=None)),
}
# Apply the three functions: k-anonymity, l-diversity and t-closeness
data_anon = k_anonymity(data, ident, quasi_ident, k, supp_level, hierarchies)
data_anon = l_diversity(
data_anon, ident, quasi_ident, sens_att, k, l_div, supp_level, hierarchies
)
data_anon = t_closeness(
data_anon, ident, quasi_ident, sens_att, k, t, supp_level, hierarchies
)
The previous code can be executed in less than 4 seconds for the more than 30,000 records of the original dataset.
License
This project is licensed under the Apache 2.0 license.
Project status
This project is under active development.
Funding and acknowledgments
This work is funded by European Union through the SIESTA project (Horizon Europe) under Grant number 101131957.
Note: Anjana and the mythology of Cantabria
"La Anjana" is a character from the mythology of Cantabria. Known as the good fairy of Cantabria, generous and protective of all people, she helps the poor, the suffering and those who stray in the forest.
- Partially extracted from: Cotera, Gustavo. Mitología de Cantabria. Ed. Tantin, Santander, 1998.
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 Distribution
File details
Details for the file anjana-0.0.1.post1.tar.gz
.
File metadata
- Download URL: anjana-0.0.1.post1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f00e34aacb30d0138f4f4eadd0bcf4d83316014f97d3efe16e0a48d348dbb2d |
|
MD5 | a00eb45ac7095f246f96808569e788a3 |
|
BLAKE2b-256 | 7cb1aae18d710bc018d0238c2a3909f5b97d1b72d1034a247c6eb298882a76b8 |
File details
Details for the file anjana-0.0.1.post1-py3-none-any.whl
.
File metadata
- Download URL: anjana-0.0.1.post1-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e9604b8112907a4b8001829b60558bbd4c5696a74f793dd74820feb33b5ecfa |
|
MD5 | e9d2fef52487cd5745f87b7bce86c3ea |
|
BLAKE2b-256 | dc7aaea4c97ab5e7a6d482a7e170147fb61c42e5c5469d905e01227eb8d79176 |