anjana.anonymity package¶
Subpackages¶
Module contents¶
Python library for applying different anonymity techniques.
- anjana.anonymity.alpha_k_anonymity(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, alpha: float | int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using (alpha,k)-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – string with the name of the sensitive attribute.
k (int) – desired level of k-anonymity.
alpha (float) – desired level of alpha for (alpha,k)-anonymity.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.basic_beta_likeness(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, beta: float | int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using basic beta-likeness and k-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – string with the name of the sensitive attribute.
k (int) – value of k for k-anonymity to be applied.
beta (float) – value of beta for basic beta-likeness to be applied.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.delta_disclosure(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, delta: float | int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using delta-disclosure privacy and k-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – str with the name of the sensitive attribute.
k (int) – value of k for k-anonymity to be applied.
delta (float) – value of delta for delta-disclosure privacy to be applied.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.enhanced_beta_likeness(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, beta: float | int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using enhanced beta-likeness and k-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – string with the name of the sensitive attribute.
k (int) – value of k for k-anonymity to be applied.
beta (float) – value of beta for enhanced beta-likeness to be applied.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.entropy_l_diversity(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, l_div: int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using entropy l-diversity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – string with the name of the sensitive attribute.
k (int) – desired level of k-anonymity.
l_div (int) – desired level of entropy l-diversity.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.k_anonymity(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, k: int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using k-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
k (int) – desired level of k-anonymity.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.k_anonymity_inner(data: ~pandas.core.frame.DataFrame, ident: list | ~numpy.ndarray, quasi_ident: list | ~numpy.ndarray, k: int, supp_level: float | int, hierarchies: dict) -> (<class 'pandas.core.frame.DataFrame'>, <class 'int'>, <class 'dict'>)¶
Auxiliary function for applying k-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
k (int) – desired level of k-anonymity.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- Returns:
number of records suppressed.
- Return type:
int
- Returns:
level of generalization applied to each QI.
- Return type:
dict
- anjana.anonymity.l_diversity(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, l_div: int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using l-diversity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – string with the name of the sensitive attribute.
k (int) – desired level of k-anonymity.
l_div (int) – desired level of l-diversity.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.recursive_c_l_diversity(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, c: int, l_div: int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using recursive (c,l)-diversity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – string with the name of the sensitive attribute.
k (int) – desired level of k-anonymity.
c (int) – desired value of c for recursive (c,l)-diversity.
l_div (int) – desired level of l-diversity.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe
- anjana.anonymity.t_closeness(data: DataFrame, ident: list | ndarray, quasi_ident: list | ndarray, sens_att: str, k: int, t: float | int, supp_level: float | int, hierarchies: dict) DataFrame¶
Anonymize a dataset using t-closeness and k-anonymity.
- Parameters:
data (pandas dataframe) – data under study.
ident (list of strings) – list with the name of the columns of the dataframe that are identifiers.
quasi_ident (list of strings) – list with the name of the columns of the dataframe that are quasi-identifiers.
sens_att (string) – str with the name of the sensitive attribute.
k (int) – value of k for k-anonymity to be applied.
t (float) – value of t for t-closeness to be applied.
supp_level (float) – maximum level of record suppression allowed (from 0 to 100).
hierarchies (dictionary containing one dictionary for QI with the hierarchies and the levels) – hierarchies for generalizing the QI.
- Returns:
anonymized data.
- Return type:
pandas dataframe