Attribute Attack

Attribute inference attacks.

class sacroml.attacks.attribute_attack.AttributeAttack(output_dir: str = 'outputs', write_report: bool = True, n_cpu: int = 3)[source]

Attribute inference attack.

Methods

attack(target)

Check whether an attack can be performed and run the attack.

attackable(target)

Return whether a target can be assessed with AttributeAttack.

get_params()

Get parameters for this attack.

classmethod attackable(target: Target) bool[source]

Return whether a target can be assessed with AttributeAttack.

__init__(output_dir: str = 'outputs', write_report: bool = True, n_cpu: int = 3) None[source]

Construct an object to execute an attribute inference attack.

Parameters:
n_cpuint

number of CPUs used to run the attack

output_dirstr

name of the directory where outputs are stored

write_reportbool

Whether to generate a JSON and PDF report.

attack(target: Target) dict

Check whether an attack can be performed and run the attack.

get_params() dict

Get parameters for this attack.

Returns:
paramsdict

Parameter names mapped to their values.

sacroml.attacks.attribute_attack.plot_categorical_fraction(res: dict, path: str = '') None[source]

Generate a bar chart showing fraction of dataset inferred.

Parameters:
resdict

Dictionary containing attribute inference attack results.

pathstr

Directory to write plots.

sacroml.attacks.attribute_attack.plot_categorical_risk(res: dict, path: str = '') None[source]

Generate a bar chart showing categorical risk scores.

Parameters:
resdict

Dictionary containing attribute inference attack results.

pathstr

Directory to write plots.

sacroml.attacks.attribute_attack.plot_quantitative_risk(res: dict, path: str = '') None[source]

Generate a bar chart showing quantitative value risk scores.

Parameters:
resdict

Dictionary containing attribute inference attack results.

pathstr

Directory to write plots.

sacroml.attacks.attribute_attack.report_categorical(results: dict) str[source]

Return a string report of the categorical results.

sacroml.attacks.attribute_attack.report_quantitative(results: dict) str[source]

Return a string report of the quantitative results.