af.model package

Submodules

af.model.Attribute module

class af.model.Attribute.Attribute(name=None, basic_type='string', privacy_type='Non-Sensitive', hierarchy=None, weight=1)[source]

Bases: object

Class that models an attribute of a table.

get_hierarchy_representation()[source]

Returns the representation of the attribute hierarchy, if any

Return type:Dictionary representation of hierarchy (None if no hierarchy associated to the attribute)
get_representation()[source]

Returns the representation of the attribute

Return type:Attribute representation in a dictionary form
is_qi_attribute()[source]

Checks if it is a qi attribute

Return type:True if it is a QI attribute, False if not
load_config(config_dict)[source]

Given a configuration, it loads the attribute based on the saved data.

Parameters:config_dict (dict) – Dictionary containing information about the attribute
set_hierarchy(hierarchy_config)[source]

Given a hierarchy configuration, load it and save it to the attribute

Parameters:hierarchy_config (dict) – hierarchy configuration in the form of a dictionary
transform(data, lvl=None)[source]

Transform original data using its particular hierarchy

Parameters:
  • data (string) – intended to be modified
  • lvl (int) – Level to generalize
Return type:

attribute value generalized to the level required

transform_leaf_nodes(lvl=1)[source]

Get the full transformation of all the leaf nodes for the attribute

Parameters:lvl (int) – Level to generalize
Return type:List of transformed values for all leaf nodes

af.model.DataConfig module

class af.model.DataConfig.DataConfig(project=None, location=None, data_type=None, table=None, attributes_list=None, anonymized_db_location=None, anonymized_table=None, metrics_table=None)[source]

Class that models all the project configuration

JSON_KEY = 'data_config'
config_representation(json_repr=True)[source]

Returns the configuration representation

Return type:Representation of the DataConfig in the form of a dictionary
get_normal_type_attributes_list()[source]

Returns those attributes that are neither identifier or qi

Return type:List of attributes not selected as identifier or qi
get_privacy_type_attributes_list(privacy_type='Quasi-Identifier')[source]

Returns those attributes that are of a certain privacy type

Parameters:privacy_type – Privacy type to filter attributes
Return type:List of attributes that match with the privacy type
load_config(data_configuration, from_json=True)[source]

Given a configuration, load it into the instance

Parameters:
  • data_configuration – Previously saved configuraton that wants to be loaded
  • from_json (bool) – Indicates if the configuration comes from a json representation or no
validate_config_to_load(config_dict)[source]

Validate the configuration that is intended to be loaded

Parameters:config_dict (dict) – Dictionary with the data configuration representation
validate_for_anonymization()[source]

Validates the data configuration to check that everything that will be needed for the anonymization process is not missing

Module contents