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
dictswhere the keys areprotected_attribute_namesand the values are values inprotected_attributes. Eachdictelement describes a single group. See examples for more details.unprivileged_groups (list(dict)) – Unprivileged groups in the same format as
privileged_groups.
- Raises:
TypeError –
datasetanddistorted_datasetmust beStructuredDatasettypes.
Methods
averageaverage_euclidean_distanceaverage_mahalanobis_distanceaverage_manhattan_distancedifferenceCompute difference of the metric for unprivileged and privileged groups.
Compute the average Euclidean distance between the samples from the two datasets.
Compute the average Mahalanobis distance between the samples from the two datasets.
Compute the average Manhattan distance between the samples from the two datasets.
maximummaximum_euclidean_distancemaximum_mahalanobis_distancemaximum_manhattan_distanceDifference of the averages.
Ratio of the averages.
Difference of the averages.
Ratio of the averages.
Difference of the averages.
Ratio of the averages.
num_instancesCompute the number of instances, \(n\), in the dataset conditioned on protected attributes if necessary.
ratioCompute ratio of the metric for unprivileged and privileged groups.
totaltotal_euclidean_distancetotal_mahalanobis_distancetotal_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
dictswhere the keys areprotected_attribute_namesand the values are values inprotected_attributes. Eachdictelement describes a single group. See examples for more details.unprivileged_groups (list(dict)) – Unprivileged groups in the same format as
privileged_groups.
- Raises:
TypeError –
datasetanddistorted_datasetmust beStructuredDatasettypes.
- 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.