8000 TST Extend tests for `scipy.sparse.*array` in `sklearn/feature_selection/tests/test_feature_select.py` by Tialo · Pull Request #27239 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 9 commits into from
Sep 13, 2023

Conversation

Tialo
Copy link
Contributor
@Tialo Tialo commented Aug 30, 2023

Reference Issues/PRs

Towards #27090.

What does this implement/fix? Explain your changes.

Any other comments?

@github-actions
Copy link
github-actions bot commented Aug 30, 2023

✔️ Linting Passed

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

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

Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @Tialo

Copy link
Member
@glemaitre glemaitre left a comment

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.

Copy link
Member
@glemaitre glemaitre left a comment

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
Copy link
Contributor Author
Tialo commented Sep 12, 2023

Thanks for fix!

@glemaitre glemaitre self-requested a review September 13, 2023 09:03
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
@glemaitre glemaitre self-requested a review September 13, 2023 09:32
Copy link
Member
@glemaitre glemaitre left a comment

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.


- |Enhancement| :func:`metrics.f_regression` and :func:`metrics.r_regression` now
supports SciPy sparse arrays.
:pr:`27239` by :user:`Tialo <Tialo>`.
Copy link
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.

Copy link
Contributor
@OmarManzoor OmarManzoor left a comment

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.

Copy link
Contributor
@OmarManzoor OmarManzoor left a comment

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
Copy link
Contributor Author
Tialo commented Sep 13, 2023

Thanks! I changed my name, ready to merge

@glemaitre glemaitre self-requested a review September 13, 2023 11:51
@glemaitre
Copy link
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
0