Closed MrMadium closed 1 year ago
AIF Version 0.5.0 Pandas: 1.3.5 Python: 3.8.10
Note on "Other" - it is one of the race categories.
from aif360.datasets import CompasDataset aif_df = CompasDataset(label_name='is_recid', favorable_classes=[0], protected_attribute_names=['sex', 'race'], privileged_classes=[['Female', 'Caucasian']], categorical_features=['age_cat', 'c_charge_degree', 'score_text'], features_to_keep=['age', 'age_cat', 'sex', 'race', 'c_charge_degree', 'priors_count', 'days_b_screening_arrest', 'decile_score', 'score_text', 'is_recid', 'two_year_recid', 'c_jail_in', 'c_jail_out'])
ValueError Traceback (most recent call last) /usr/local/lib/python3.8/dist-packages/aif360/datasets/structured_dataset.py in init(self, df, label_names, protected_attribute_names, instance_weights_name, scores_names, unprivileged_protected_attributes, privileged_protected_attributes, metadata) 95 try: ---> 96 df = df.astype(np.float64) 97 except ValueError as e:
12 frames ValueError: could not convert string to float: 'Other'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last) /usr/local/lib/python3.8/dist-packages/aif360/datasets/structured_dataset.py in init(self, df, label_names, protected_attribute_names, instance_weights_name, scores_names, unprivileged_protected_attributes, privileged_protected_attributes, metadata) 97 except ValueError as e: 98 print("ValueError: {}".format(e)) ---> 99 raise ValueError("DataFrame values must be numerical.") 100 101 # Convert all column names to strings
ValueError: DataFrame values must be numerical.
Had to cast the column in the 'categorical_features' column by the look of it. Apologies.
AIF Version 0.5.0 Pandas: 1.3.5 Python: 3.8.10
Note on "Other" - it is one of the race categories.
ValueError: could not convert string to float: 'Other'
ValueError Traceback (most recent call last) /usr/local/lib/python3.8/dist-packages/aif360/datasets/structured_dataset.py in init(self, df, label_names, protected_attribute_names, instance_weights_name, scores_names, unprivileged_protected_attributes, privileged_protected_attributes, metadata) 95 try: ---> 96 df = df.astype(np.float64) 97 except ValueError as e:
12 frames ValueError: could not convert string to float: 'Other'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last) /usr/local/lib/python3.8/dist-packages/aif360/datasets/structured_dataset.py in init(self, df, label_names, protected_attribute_names, instance_weights_name, scores_names, unprivileged_protected_attributes, privileged_protected_attributes, metadata) 97 except ValueError as e: 98 print("ValueError: {}".format(e)) ---> 99 raise ValueError("DataFrame values must be numerical.") 100 101 # Convert all column names to strings
ValueError: DataFrame values must be numerical.