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 erroranalysis conversion exception with object detection task for complex pred Y and true Y data and numpy>=1.26.0 by specifying object type #2594

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

imatiach-msft
Copy link
Contributor

Description

Fix erroranalysis conversion exception with object detection task for complex pred Y and true Y data and numpy>=1.26.0 by specifying object type.

With numpy>=1.26.0 erroranalysis package throws exception:

...
  File "/azureml-envs/responsibleai-vision/lib/python3.9/site-packages/responsibleai/managers/error_analysis_manager.py", line 337, in compute
    report = self._analyzer.create_error_report(
  File "/azureml-envs/responsibleai-vision/lib/python3.9/site-packages/erroranalysis/analyzer/error_analyzer.py", line 423, in create_error_report
    tree = self.compute_error_tree(self.feature_names,
  File "/azureml-envs/responsibleai-vision/lib/python3.9/site-packages/erroranalysis/analyzer/error_analyzer.py", line 344, in compute_error_tree
    return _compute_error_tree(self,
  File "/azureml-envs/responsibleai-vision/lib/python3.9/site-packages/erroranalysis/_internal/surrogate_error_tree.py", line 266, in compute_error_tree
    return compute_error_tree_on_dataset(
  File "/azureml-envs/responsibleai-vision/lib/python3.9/site-packages/erroranalysis/_internal/surrogate_error_tree.py", line 169, in compute_error_tree_on_dataset
    booster, dataset_indexed_df, cat_info = get_surrogate_booster_local(
  File "/azureml-envs/responsibleai-vision/lib/python3.9/site-packages/erroranalysis/_internal/surrogate_error_tree.py", line 345, in get_surrogate_booster_local
    pred_y = np.array(pred_y)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (10,) + inhomogeneous part.

Based on stackoverflow suggestion:
https://stackoverflow.com/questions/67183501/setting-an-array-element-with-a-sequence-requested-array-has-an-inhomogeneous-sh

The fix is to use numpy object type when converting list to numpy array for complex data which is used in tasks like object detection. A test was also added to reproduce the exception locally and validate that the issue is resolved after the type cast was added for newer numpy>=1.26.0.

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.

@imatiach-msft imatiach-msft force-pushed the ilmat/fix-ea-od-err branch 4 times, most recently from c90c654 to 796058f Compare January 15, 2025 19:10
@imatiach-msft imatiach-msft force-pushed the ilmat/fix-ea-od-err branch 2 times, most recently from 6618c4f to 1aef947 Compare January 15, 2025 19:19
… complex pred Y and true Y data and numpy>=1.26.0 by specifying object type
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 87.84%. Comparing base (dfa37be) to head (1aef947).

Files with missing lines Patch % Lines
...is/erroranalysis/_internal/surrogate_error_tree.py 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2594      +/-   ##
==========================================
- Coverage   87.89%   87.84%   -0.05%     
==========================================
  Files         113      113              
  Lines        6648     6657       +9     
==========================================
+ Hits         5843     5848       +5     
- Misses        805      809       +4     
Flag Coverage Δ
unittests 87.84% <71.42%> (-0.05%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

4 participants