Skip to content

fix: convert age and education-num to numeric in load_preproc_data_adult - #579

Open
aniruddhaadak80 wants to merge 1 commit into
Trusted-AI:mainfrom
aniruddhaadak80:fix-load-preproc-data-adult
Open

aniruddhaadak80 wants to merge 1 commit into
Trusted-AI:mainfrom
aniruddhaadak80:fix-load-preproc-data-adult

Conversation

@aniruddhaadak80

Copy link
Copy Markdown

Summary

Fixes #421: load_preproc_data_adult fails with TypeError: unsupported operand type(s) for //: 'str' and 'int' when the age column is read as strings.

Root Cause

The custom_preprocessing function in data_preproc_functions.py applies arithmetic operations (//, <=, >=) directly on the age and education-num columns. When these columns are read as strings (e.g., due to CSV formatting with leading spaces), the operations fail.

Fix

Added pd.to_numeric() conversion for both age and education-num columns before applying arithmetic operations in the custom_preprocessing function of load_preproc_data_adult.

Files Changed

  • aif360/algorithms/preprocessing/optim_preproc_helpers/data_preproc_functions.py: Added pd.to_numeric() calls for age and education-num columns

Testing

  • Verified the fix resolves the TypeError when age/education-num columns contain string values
  • Confirmed the output values are correct after conversion

Signed-off-by: Aniruddha Adak <aniruddhaadak80@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken load_preproc_data_adult

1 participant