aif360.datasets.CompasDataset¶
-
class
aif360.datasets.CompasDataset(label_name='two_year_recid', favorable_classes=[0], protected_attribute_names=['sex', 'race'], privileged_classes=[['Female'], ['Caucasian']], instance_weights_name=None, categorical_features=['age_cat', 'c_charge_degree', 'c_charge_desc'], features_to_keep=['sex', 'age', 'age_cat', 'race', 'juv_fel_count', 'juv_misd_count', 'juv_other_count', 'priors_count', 'c_charge_degree', 'c_charge_desc', 'two_year_recid'], features_to_drop=[], na_values=[], custom_preprocessing=<function default_preprocessing>, metadata={'label_maps': [{1.0: 'Did recid.', 0.0: 'No recid.'}], 'protected_attribute_maps': [{0.0: 'Male', 1.0: 'Female'}, {1.0: 'Caucasian', 0.0: 'Not Caucasian'}]})[source]¶ ProPublica COMPAS Dataset.
See
aif360/data/raw/compas/README.md.See
StandardDatasetfor a description of the arguments.Note: The label value 0 in this case is considered favorable (no recidivism).
Examples
In some cases, it may be useful to keep track of a mapping from
float -> strfor protected attributes and/or labels. If our use case differs from the default, we can modify the mapping stored inmetadata:>>> label_map = {1.0: 'Did recid.', 0.0: 'No recid.'} >>> protected_attribute_maps = [{1.0: 'Male', 0.0: 'Female'}] >>> cd = CompasDataset(protected_attribute_names=['sex'], ... privileged_classes=[['Male']], metadata={'label_map': label_map, ... 'protected_attribute_maps': protected_attribute_maps})
Now this information will stay attached to the dataset and can be used for more descriptive visualizations.
Methods
align_datasetsAlign the other dataset features, labels and protected_attributes to this dataset. convert_to_dataframeConvert the StructuredDataset to a pandas.DataFrame.copyConvenience method to return a copy of this dataset. export_datasetExport the dataset and supporting attributes TODO: The preferred file format is HDF import_datasetImport the dataset and supporting attributes TODO: The preferred file format is HDF splitSplit this dataset into multiple partitions. subsetSubset of dataset based on position :param indexes: iterable which contains row indexes temporarily_ignoreTemporarily add the fields provided to ignore_fields.validate_datasetError checking and type validation. -
__init__(label_name='two_year_recid', favorable_classes=[0], protected_attribute_names=['sex', 'race'], privileged_classes=[['Female'], ['Caucasian']], instance_weights_name=None, categorical_features=['age_cat', 'c_charge_degree', 'c_charge_desc'], features_to_keep=['sex', 'age', 'age_cat', 'race', 'juv_fel_count', 'juv_misd_count', 'juv_other_count', 'priors_count', 'c_charge_degree', 'c_charge_desc', 'two_year_recid'], features_to_drop=[], na_values=[], custom_preprocessing=<function default_preprocessing>, metadata={'label_maps': [{1.0: 'Did recid.', 0.0: 'No recid.'}], 'protected_attribute_maps': [{0.0: 'Male', 1.0: 'Female'}, {1.0: 'Caucasian', 0.0: 'Not Caucasian'}]})[source]¶ See
StandardDatasetfor a description of the arguments.Note: The label value 0 in this case is considered favorable (no recidivism).
Examples
In some cases, it may be useful to keep track of a mapping from
float -> strfor protected attributes and/or labels. If our use case differs from the default, we can modify the mapping stored inmetadata:>>> label_map = {1.0: 'Did recid.', 0.0: 'No recid.'} >>> protected_attribute_maps = [{1.0: 'Male', 0.0: 'Female'}] >>> cd = CompasDataset(protected_attribute_names=['sex'], ... privileged_classes=[['Male']], metadata={'label_map': label_map, ... 'protected_attribute_maps': protected_attribute_maps})
Now this information will stay attached to the dataset and can be used for more descriptive visualizations.
-