tapas.threat_models.mia.MIALabeller
- class tapas.threat_models.mia.MIALabeller(attacker_knowledge: AttackerKnowledgeOnData, target_records: Dataset, generate_pairs=True, replace_target=False)
Bases:
tapas.threat_models.attacker_knowledge.AttackerKnowledgeWithLabelRandomly add a given target to the datasets sampled from auxiliary data. This class can be used to augment AttackerKnowledgeOnData objects that represent “generic” knowledge of the private dataset in order to use them for membership inference attacks.
You may use this explicitly to feed into a LabelInferenceThreatModel, but this is meant mostly as an internal method to make MIAs.
- __init__(attacker_knowledge: AttackerKnowledgeOnData, target_records: Dataset, generate_pairs=True, replace_target=False)
Wrap an AttackerKnowledgeOnData object by appending a record.
- Parameters
attacker_knowledge (AttackerKnowledgeOnData) – The data knowledge from which datasets are generated.
target_records (Dataset) – The target records to append to the dataset. If several records are provided, these records are randomly added to the dataset independently from each other.
generate_pairs (bool, default True) – Whether to output pairs of datasets differing only by the presence of the target record, or randomly choose for each dataset. If multiple targets are provided, then the pairs of datasets differ by exactly all of the multiple targets (as in, if a record x from the targets is in D, it is not in D’, but the membership of each target is independent from the other targets).
replace_target (bool, default False) – Whether to replace a record, instead of appending.
Methods
__init__(attacker_knowledge, target_records)Wrap an AttackerKnowledgeOnData object by appending a record.
generate_datasets(num_samples[, training])Generate num_samples training or testing datasets.
generate_datasets_with_label(num_samples[, ...])Generate num_samples training or testing datasets with corresponding labels (arbitrary ints or bools).
Attributes
A string to represent this knowledge.
- abstract generate_datasets(num_samples: int, training: bool = True) list[Dataset]
Generate num_samples training or testing datasets.
- generate_datasets_with_label(num_samples: int, training: bool = True) tuple[list[Dataset], list[int]]
Generate num_samples training or testing datasets with corresponding labels (arbitrary ints or bools).
- property label
A string to represent this knowledge.