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 isnan exception in erroranalysis for newer versions of pandas and numpy when calling qcut #1784

Merged
merged 1 commit into from
Oct 24, 2022

Conversation

imatiach-msft
Copy link
Contributor

@imatiach-msft imatiach-msft commented Oct 21, 2022

Description

Fix isnan exception in erroranalysis for newer versions of pandas and numpy when calling qcut.

When going to heatmap, in some environments with python 3.8 installed and latest versions of pandas and numpy, erroranalysis matrix_filter method would fail with error:

\responsibleai\responsible-ai-widgets\erroranalysis\erroranalysis\_internal\matrix_filter.py", line 365, in bin_data\n bindf = pd.qcut(feat_col, bins, precision=PRECISION, duplicates=DROP)\n \.conda\envs\big_data\lib\site-packages\pandas\core\reshape\tile.py", line 375, in qcut\n x_np = x_np[~np.isnan(x_np)]\nTypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''\n"

The solution was to change to more specific dtypes using convert_dtypes() for pandas dataframe after making a copy, since the copy was changing all types to object dtype.

Since qcut was failing on object dtype column when creating the dataframe copy, changing to more specify number type via convert_dtypes() fixed the error.

Checklist

  • I have added screenshots above for all UI changes.
  • I have added e2e tests for all UI changes.
  • Documentation was updated if it was needed.

@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2022

Codecov Report

Merging #1784 (483a995) into main (fd233b3) will increase coverage by 7.52%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1784      +/-   ##
==========================================
+ Coverage   75.72%   83.25%   +7.52%     
==========================================
  Files          16       19       +3     
  Lines        1141      406     -735     
==========================================
- Hits          864      338     -526     
+ Misses        277       68     -209     
Flag Coverage Δ
unittests 83.25% <ø> (+7.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
raiwidgets/raiwidgets/error_analysis_constants.py
raiwidgets/raiwidgets/dashboard.py
raiwidgets/raiwidgets/cohort.py
...iwidgets/raiwidgets/explanation_dashboard_input.py
raiwidgets/raiwidgets/error_handling.py
raiwidgets/raiwidgets/explanation_dashboard.py
...idgets/raiwidgets/responsibleai_dashboard_input.py
raiwidgets/raiwidgets/responsibleai_dashboard.py
...dgets/raiwidgets/error_analysis_dashboard_input.py
...iwidgets/raiwidgets/fairness_metric_calculation.py
... and 25 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@gaugup
Copy link
Contributor

gaugup commented Oct 21, 2022

can you describe what the fix does?

@imatiach-msft
Copy link
Contributor Author

"can you describe what the fix does?"
I added another sentence at the end to help clarify.

@imatiach-msft imatiach-msft merged commit 2b9b16c into main Oct 24, 2022
@imatiach-msft imatiach-msft deleted the ilmat/fix-isnan-err branch October 24, 2022 04:33
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.

5 participants