LocalRecodingAlgorithm

LocalRecodingAlgorithm#

class LocalRecodingAlgorithm(dataset: Dataset, k: int, group_anonymization: GroupAnonymization = <function GroupAnonymizationBuiltIn.SUMMARIZATION>)#

Bases: Algorithm

Abstract class for local recoding-based k-anonymization algorithms.

Parameters:
  • dataset (Dataset) – The Dataset object holding the original data and its metadata.

  • k (int) – The privacy parameter ‘k’.

  • group_anonymization (GroupAnonymization) – The method to anonymize the resulting groups after applying local recoding. It is possible to use an example method in GroupAnonymizationBuiltIn, or create a custom method custom_group_anonymization(group: list, props: Any) -> list. Default: GroupAnonymizationBuiltIn.SUMMARIZATION

Variables:
  • [...] (attributes inherited from Algorithm)

  • group_anonymization (GroupAnonymization) – Group anonymization method.

  • groups (list | None) – List of groups of original records after applying local recoding (before applying the group anonymization method)

  • max_ranges (list[int | None]) – Maximum range (or unique count) for each QID attribute.

Methods

anonymize

Execute the local recoding anonymization workflow.

do_local_recoding

Split the original data into groups of records.

anonymize()#

Execute the local recoding anonymization workflow.

The process follows these steps:

  1. Inject temporary IDs to track original row ordering.

  2. Split data into groups using do_local_recoding.

  3. Apply the group anonymization strategy to each group.

  4. Reconstruct the dataset and restore original row order.

  5. Clean up temporary IDs.

abstractmethod do_local_recoding()#

Split the original data into groups of records.

This abstract method must be implemented by subclasses to define how the data is split into groups that satisfy k-anonymity.

Returns:

list – A list of groups, where each group contains records from the original data