Skip to content

TST Extend tests for scipy.sparse.*array in sklearn/feature_selection/tests/test_feature_select.py - #27239

Merged
glemaitre merged 9 commits into
scikit-learn:mainfrom
Tialo:tests/test_feature_select
Sep 13, 2023
Merged

glemaitre merged 9 commits into
scikit-learn:mainfrom
Tialo:tests/test_feature_select

Conversation

@Tialo

@Tialo Tialo commented Aug 30, 2023

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Towards #27090.

What does this implement/fix? Explain your changes.

Any other comments?

@github-actions

github-actions Bot commented Aug 30, 2023 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: fbd2716. Link to the linter CI: here

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @Tialo

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the implementation of r_regression is not compatible. I have to check the reason.

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to edit the file sklearn/feature_selection/_univariate_selection.py in l.326 and replace the code from:

        if issparse(X):
            X_means = X.mean(axis=0).getA1()
        else:
            X_means = X.mean(axis=0)

to

        if isspmatrix(X):
            X_means = X.mean(axis=0).getA1()
        else:
            X_means = X.mean(axis=0)

You should import isspmatrix from scipy.sparse

@Tialo
Tialo force-pushed the tests/test_feature_select branch from a18e73c to 180013a Compare September 12, 2023 20:49
@Tialo

Tialo commented Sep 12, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for fix!

@glemaitre
glemaitre self-requested a review September 13, 2023 09:03
Comment thread sklearn/feature_selection/_univariate_selection.py Outdated
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
@glemaitre
glemaitre self-requested a review September 13, 2023 09:32

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the linting problem by removing the useless import. I also added an entry in the changelog at the same time since we are modifying some public facing code.

LGTM otherwise. @OmarManzoor feel free to have a look at this one.

Comment thread doc/whats_new/v1.4.rst Outdated

- |Enhancement| :func:`metrics.f_regression` and :func:`metrics.r_regression` now
supports SciPy sparse arrays.
:pr:`27239` by :user:`Tialo <Tialo>`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to update your name (only the first mention since the second one link to your GitHub handle). This is also fine keeping it as-is.

@OmarManzoor OmarManzoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Tialo for the PR.

Comment thread doc/whats_new/v1.4.rst Outdated
Comment thread sklearn/feature_selection/_univariate_selection.py Outdated

@OmarManzoor OmarManzoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the minor changes. LGTM.

@Tialo

Tialo commented Sep 13, 2023

Copy link
Copy Markdown
Contributor Author

Thanks! I changed my name, ready to merge

@glemaitre
glemaitre self-requested a review September 13, 2023 11:51
@glemaitre

Copy link
Copy Markdown
Member

Oh apparently there is a new deprecation warning. I made the changes. We should be good to go.
I enable the auto-merge if the CIs are passing.

@glemaitre
glemaitre enabled auto-merge (squash) September 13, 2023 11:54
@glemaitre
glemaitre merged commit f54212f into scikit-learn:main Sep 13, 2023
@Tialo
Tialo deleted the tests/test_feature_select branch September 13, 2023 12:52
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
…ion/tests/test_feature_select.py` (scikit-learn#27239)

Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Omar Salman <omar.salman@arbisoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants