aif360.metrics.SampleDistortionMetric

class aif360.metrics.SampleDistortionMetric(dataset, distorted_dataset, unprivileged_groups=None, privileged_groups=None)[source]

Class for computing metrics based on two StructuredDatasets.

Parameters:
  • dataset (StructuredDataset) – A StructuredDataset.

  • distorted_dataset (StructuredDataset) – A StructuredDataset.

  • privileged_groups (list(dict)) – Privileged groups. Format is a list of dicts where the keys are protected_attribute_names and the values are values in protected_attributes. Each dict element describes a single group. See examples for more details.

  • unprivileged_groups (list(dict)) – Unprivileged groups in the same format as privileged_groups.

Raises:

TypeErrordataset and distorted_dataset must be StructuredDataset types.

Methods

average

average_euclidean_distance

average_mahalanobis_distance

average_manhattan_distance

difference

Compute difference of the metric for unprivileged and privileged groups.

euclidean_distance

Compute the average Euclidean distance between the samples from the two datasets.

mahalanobis_distance

Compute the average Mahalanobis distance between the samples from the two datasets.

manhattan_distance

Compute the average Manhattan distance between the samples from the two datasets.

maximum

maximum_euclidean_distance

maximum_mahalanobis_distance

maximum_manhattan_distance

mean_euclidean_distance_difference

Difference of the averages.

mean_euclidean_distance_ratio

Ratio of the averages.

mean_mahalanobis_distance_difference

Difference of the averages.

mean_mahalanobis_distance_ratio

Ratio of the averages.

mean_manhattan_distance_difference

Difference of the averages.

mean_manhattan_distance_ratio

Ratio of the averages.

num_instances

Compute the number of instances, \(n\), in the dataset conditioned on protected attributes if necessary.

ratio

Compute ratio of the metric for unprivileged and privileged groups.

total

total_euclidean_distance

total_mahalanobis_distance

total_manhattan_distance

__init__(dataset, distorted_dataset, unprivileged_groups=None, privileged_groups=None)[source]
Parameters:
  • dataset (StructuredDataset) – A StructuredDataset.

  • distorted_dataset (StructuredDataset) – A StructuredDataset.

  • privileged_groups (list(dict)) – Privileged groups. Format is a list of dicts where the keys are protected_attribute_names and the values are values in protected_attributes. Each dict element describes a single group. See examples for more details.

  • unprivileged_groups (list(dict)) – Unprivileged groups in the same format as privileged_groups.

Raises:

TypeErrordataset and distorted_dataset must be StructuredDataset types.

euclidean_distance(privileged=None, returned=False)[source]

Compute the average Euclidean distance between the samples from the two datasets.

mahalanobis_distance(privileged=None, returned=False)[source]

Compute the average Mahalanobis distance between the samples from the two datasets.

manhattan_distance(privileged=None, returned=False)[source]

Compute the average Manhattan distance between the samples from the two datasets.

mean_euclidean_distance_difference(privileged=None)[source]

Difference of the averages.

mean_euclidean_distance_ratio(privileged=None)[source]

Ratio of the averages.

mean_mahalanobis_distance_difference(privileged=None)[source]

Difference of the averages.

mean_mahalanobis_distance_ratio(privileged=None)[source]

Ratio of the averages.

mean_manhattan_distance_difference(privileged=None)[source]

Difference of the averages.

mean_manhattan_distance_ratio(privileged=None)[source]

Ratio of the averages.