Where: explainers/counterfactual-explanation.md's nearest_counterfactual() and its "ORIGINAL APPLICATION" worked example.
Bug 1 - TypeError on the file's own worked example: the example instance (credit_amount: 4800, duration_months: 36, employment_years: 1, existing_credits: 2 - all whole numbers) is built into a pandas Series, which infers int64 dtype. nearest_counterfactual()'s perturbation step (candidate[feature] = np.clip(candidate[feature] + delta, low, high)) then tries to write a float perturbation into that int64 slot:
TypeError: Invalid value '...' for dtype 'int64'
(confirmed under pandas 3.0.3, the version pinned in requirements-lock.txt, using the file's own example values).
Bug 2 - nonexistent columns: the same worked example and its "Usage example" use duration_months and employment_years. The real German Credit Lending/credit_customers.csv (the dataset this repo's unfair.py/fair.py/audit.yaml actually use) has no such columns - the real columns are duration (numeric months) and employment (a categorical bucket: '>=7', '1<=X<4', '4<=X<7', 'unemployed', '<1'), not a plain integer year count.
Fix direction: cast the instance Series to float64 before perturbation (fixing bug 1 in a dataset-independent way), and rename the worked example's columns to the real duration/employment (adjusting the employment value to a real bucket string rather than an integer year count, fixing bug 2).
Where:
explainers/counterfactual-explanation.md'snearest_counterfactual()and its "ORIGINAL APPLICATION" worked example.Bug 1 - TypeError on the file's own worked example: the example instance (
credit_amount: 4800, duration_months: 36, employment_years: 1, existing_credits: 2- all whole numbers) is built into a pandas Series, which infersint64dtype.nearest_counterfactual()'s perturbation step (candidate[feature] = np.clip(candidate[feature] + delta, low, high)) then tries to write a float perturbation into that int64 slot:(confirmed under pandas 3.0.3, the version pinned in
requirements-lock.txt, using the file's own example values).Bug 2 - nonexistent columns: the same worked example and its "Usage example" use
duration_monthsandemployment_years. The realGerman Credit Lending/credit_customers.csv(the dataset this repo'sunfair.py/fair.py/audit.yamlactually use) has no such columns - the real columns areduration(numeric months) andemployment(a categorical bucket:'>=7','1<=X<4','4<=X<7','unemployed','<1'), not a plain integer year count.Fix direction: cast the instance Series to
float64before perturbation (fixing bug 1 in a dataset-independent way), and rename the worked example's columns to the realduration/employment(adjusting the employment value to a real bucket string rather than an integer year count, fixing bug 2).