metasyn.privacy

Module with privacy classes to be used for creating GMF files.

Functions

get_privacy(name[, parameters])

Create a new privacy object using a name and parameters.

metasyn.privacy.get_privacy(name, parameters=None)

Create a new privacy object using a name and parameters.

Parameters:
  • name (str) – Name of the privacy type, use “none” for no specific type of privacy.

  • parameters (Optional[dict]) – The parameters for the privacy type. This could be the epsilon for differential privacy or partition_size for disclosure control, by default None.

Return type:

BasePrivacy

Returns:

A new instantiated object for privacy.

Raises:

KeyError – If the name of the privacy type cannot be found.

Classes

BasePrivacy()

Abstract base class for privacy levels.

BasicPrivacy()

Class representing no privacy level.

class metasyn.privacy.BasePrivacy

Bases: ABC

Abstract base class for privacy levels.

This class serves as a blueprint for privacy classes. Derived classes should at least set the class variable name and implement the to_dict method, which should return a dictionary that gives the privacy type and its parameters.

abstractmethod to_dict()

Create a dictionary that gives the privacy type, and parameters.

Return type:

dict

is_compatible(dist)

Check whether the distribution has the same privacy.

Parameters:

dist (Union[BaseFitter, Type[BaseFitter]]) – Distribution to check.

Return type:

bool

comment(var)

Comment on the privacy features for the TOML GMF file.

Parameters:

col_name – Name of the column.

Returns:

A comment on the privacy features.

class metasyn.privacy.BasicPrivacy

Bases: BasePrivacy

Class representing no privacy level.

This class uses statistically optimal distributions. It inherits from the BasePrivacy class and sets the name attribute to “none”.

to_dict()

Create a dictionary that gives the privacy type, and parameters.

Return type:

dict