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 builds by supporting sparse_output renamed parameter in OneHotEncoder in new scikit-learn version update #2507

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

imatiach-msft
Copy link
Contributor

Description

fix builds by supporting sparse_output renamed parameter in OneHotEncoder in new scikit-learn version update

Builds are failing due to a parameter rename in scikit-learn package, which just recently released a new version:

https://github.com/microsoft/responsible-ai-toolbox/actions/runs/7619055180/job/20874745412?pr=2499

                ("imputer",
                    SimpleImputer(strategy='constant', fill_value='missing')),
>               ("encoder", OneHotEncoder(sparse=False))]), ["embarked"]),
            ("sex_pclass", OneHotEncoder(sparse=False), ["sex", "pclass"])
        ])
E       TypeError: __init__() got an unexpected keyword argument 'sparse'

For more context please see scikit-learn docs:
https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html

sparse_outputbool, default=True
When True, it returns a [scipy.sparse.csr_matrix](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html#scipy.sparse.csr_matrix), i.e. a sparse matrix in “Compressed Sparse Row” (CSR) format.

New in version 1.2: sparse was renamed to sparse_output

This PR updates notebooks and test utilities to support both variants depending on the scikit-learn version in the build.
Note that rai-test-utils will need to be released at some point with the updates. For now, I've added a local install where required in the builds.

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 Jan 26, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (7ff3476) 83.05% compared to head (e8c92c3) 92.36%.

Files Patch % Lines
...i_test_utils/models/sklearn/sklearn_model_utils.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2507      +/-   ##
==========================================
+ Coverage   83.05%   92.36%   +9.31%     
==========================================
  Files          65      108      +43     
  Lines        3169     5424    +2255     
==========================================
+ Hits         2632     5010    +2378     
+ Misses        537      414     -123     
Flag Coverage Δ
unittests 92.36% <40.00%> (+9.31%) ⬆️

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.

2 similar comments
@imatiach-msft imatiach-msft merged commit 66e33cb into main Jan 26, 2024
129 of 130 checks passed
@imatiach-msft imatiach-msft deleted the ilmat/update-sparse-output branch January 26, 2024 22:00
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.

3 participants