tapas.report.attack_summary.AIAttackSummary

class tapas.report.attack_summary.AIAttackSummary(labels, predictions, scores=None, generator_info='', attack_info='', dataset_info='', target_id='', sensitive_attribute='')

Bases: tapas.report.attack_summary.LabelInferenceAttackSummary

Class summarising the outputs of an attribute inference attack.

__init__(labels, predictions, scores=None, generator_info='', attack_info='', dataset_info='', target_id='', sensitive_attribute='')
Parameters
  • labels (list[int]) – List with true labels of the target membership in the dataset.

  • predictions (list[int]) – List with the predicted labels of the target membership in the dataset.

  • scores (list[float]) – List with the scores related to each prediction.

  • generator_info (str) – Metadata with information about the method used to generate the dataset.

  • attack_info (str) – Metadata with information about the attacked used to infer membership of the target on the dataset.

  • dataset_info (str) – Metadata with information about the original raw dataset.

  • target_id (str) – Metadata with information about the target record used on the attack.

  • sensitive_attribute (str) – The name of the sensitive attribute that the attack aims to infer.

Methods

__init__(labels, predictions[, scores, ...])

param labels

List with true labels of the target membership in the dataset.

get_header()

Returns a Pandas DataFrame with the description of the parameters of the AIA.

get_metric_filename([postfix])

Returns the file name to which results should be saved.

get_metrics()

Calculates all AIA relevant metrics and returns them as a dataframe.

write_metrics(output_path[, postfix])

Write metrics to file.

Attributes

accuracy

Accuracy of the attacks based on the rate of correct predictions.

property accuracy

Accuracy of the attacks based on the rate of correct predictions.

Return type

float

get_header()

Returns a Pandas DataFrame with the description of the parameters of the AIA.

get_metric_filename(postfix='')

Returns the file name to which results should be saved.

get_metrics()

Calculates all AIA relevant metrics and returns them as a dataframe.

Returns

A dataframe with attack info and metrics. The dataframe has the following structure. Index:

RangeIndex

Columns:

dataset: str target_id: str generator: str attack: str sensitive_attribute: str accuracy: float

Return type

A dataframe

write_metrics(output_path, postfix='')

Write metrics to file.

Parameters
  • output_path (str) – The prefix of the path where the metrics should be saved.

  • postfix (str) – An optional string to append to the filename