privacy_metric#

privacy_metric(X, X_bool, sensible_attribute, k_anonymity, l_diversity, t_closeness, strict, categorical, use_t)[source]#

Evaluates privacy preservation based on k-anonymity, l-diversity, and t-closeness.

This function checks whether a split of the data satisfies specified privacy constraints.

Parameters:
  • X (array-like) – The dataset features

  • X_bool (array-like) – Boolean array indicating the split (True/False for each instance)

  • sensible_attribute (int or list) – Index or indices of the sensitive attribute(s) in X

  • k_anonymity (int or float) – Minimum required k-anonymity level. If float, interpreted as a proportion

  • l_diversity (int) – Minimum required l-diversity level

  • t_closeness (float) – Maximum allowed t-closeness value

  • strict (bool) – If True, enforces all privacy constraints strictly

  • categorical (bool) – Whether the sensitive attribute is categorical

  • use_t (bool) – Whether to compute and use t-closeness in the evaluation

Returns:

(is_valid, k, l, t) where: - is_valid: boolean indicating if privacy constraints are satisfied - k: achieved k-anonymity value - l: achieved l-diversity value - t: achieved t-closeness value or np.nan if not computed

Return type:

tuple