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

[Resolved] get_disparity_predefined_group() raises TypeError #78

Closed
LiFaytheGoblin opened this issue Jun 16, 2020 · 1 comment
Closed

Comments

@LiFaytheGoblin
Copy link

LiFaytheGoblin commented Jun 16, 2020

Hi everyone,

I am a CS student and I am trying out your Aequitas COMPAS analysis example.

When I run https://github.com/dssg/aequitas/blob/master/docs/source/examples/compas_demo.ipynb on my local machine (Python 3), when trying to execute the cell with code

bdf = b.get_disparity_predefined_groups(xtab, original_df=df, 
                                        ref_groups_dict={'race':'Caucasian', 'sex':'Male', 'age_cat':'25 - 45'}, 
                                        alpha=0.05, check_significance=True, 
                                        mask_significance=True)
bdf.style

I get the error

TypeError: Input must be Index or array-like

With the following details:

get_disparity_predefined_group()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-46-a7be4e5ab5de> in <module>
      2                                         ref_groups_dict={'race':'Caucasian', 'sex':'Male', 'age_cat':'25 - 45'},
      3                                         alpha=0.05, check_significance=True,
----> 4                                         mask_significance=True)
      5 bdf.style

C:\Program_Files\Anaconda3\lib\site-packages\aequitas\bias.py in get_disparity_predefined_groups(self, df, original_df, ref_groups_dict, key_columns, input_group_metrics, fill_divbyzero, check_significance, alpha, mask_significance)
    370             # for predefined groups, use the largest of the predefined groups as
    371             # ref group for score and label value
--> 372             check_significance = df_cols.intersection(check_significance).tolist()
    373 
    374             # compile dictionary of reference groups based on bias-augmented crosstab

C:\Program_Files\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in intersection(self, other, sort)
   2391         """
   2392         self._validate_sort_keyword(sort)
-> 2393         self._assert_can_do_setop(other)
   2394         other = ensure_index(other)
   2395 

C:\Program_Files\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in _assert_can_do_setop(self, other)
   2590     def _assert_can_do_setop(self, other):
   2591         if not is_list_like(other):
-> 2592             raise TypeError('Input must be Index or array-like')
   2593         return True
   2594 

Does this run on your own Notebook? If so, any guesses why it doesn't work for me?


EDIT:
The problem seems to be that when I installed Aequitas using pip it did not install the up to date version? My version is 38.0 and apparently there is a newer version 38.1.

EDIT2:
Yup, it works now, updating the version of aequitas was it :)

@LiFaytheGoblin LiFaytheGoblin changed the title get_disparity_predefined_group() raises TypeError [Resolved] get_disparity_predefined_group() raises TypeError Jun 16, 2020
@lorenh516
Copy link
Collaborator

Wonderful, glad this was so quickly resolved! We will look into the pip versioning issue, thank you for flagging.

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

No branches or pull requests

3 participants