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 areprotected_attribute_names
and the values are values inprotected_attributes
. Eachdict
element describes a single group. See examples for more details.unprivileged_groups (list(dict)) – Unprivileged groups in the same format as
privileged_groups
.
- Raises:
TypeError –
dataset
anddistorted_dataset
must beStructuredDataset
types.
Methods
average
average_euclidean_distance
average_mahalanobis_distance
average_manhattan_distance
difference
Compute 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.
maximum
maximum_euclidean_distance
maximum_mahalanobis_distance
maximum_manhattan_distance
Difference of the averages.
Ratio of the averages.
Difference of the averages.
Ratio of the averages.
Difference of the averages.
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 areprotected_attribute_names
and the values are values inprotected_attributes
. Eachdict
element describes a single group. See examples for more details.unprivileged_groups (list(dict)) – Unprivileged groups in the same format as
privileged_groups
.
- Raises:
TypeError –
dataset
anddistorted_dataset
must beStructuredDataset
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.