Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sorting of dataframe for aequitas calculations during evaluations #858

Merged
merged 4 commits into from
Aug 26, 2021

Conversation

shaycrk
Copy link
Contributor

@shaycrk shaycrk commented Aug 17, 2021

Currently, the attributes for bias analysis via aequitas are getting scrambled relative to the scores and labels when the latter get sorted for "best case" and "worst case" analyses. To fix this issue, this PR sorts the index (e.g., the entity_id, as_of_date tuple) as well, then applies this re-sorted index to the dataframe with the attributes used for aequitas calculations.

Also note that I added a check that raises a ValueError if there is a mismatch between the indices for the protected_df and labels (the must have the same shape and sets of unique values). This will enforce that protected_df covers the full set of entities and has no duplicates, which I don't think is an unreasonable requirement for running the bias analysis, but if anyone disagrees, we can remove the check.

@shaycrk shaycrk merged commit 46e96d3 into master Aug 26, 2021
@shaycrk shaycrk deleted the kit_aequitas_sorting branch August 26, 2021 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants