Skip to content

FEAT rfecv: add support and ranking for each cv and step #30179

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

Conversation

MarieSacksick
Copy link
Contributor

Reference Issues/PRs

Fixes #17782

What does this implement/fix? Explain your changes.

It gives the option to access the ranking and support in each iteration and cv step.
As of today, it is possible to know what looks like to be the best number of features to chose, but we can't know if each cv converged towards the same best selection. Having access to these also allows to have a better view on the stability and therefore reliability.

Any other comments?

I chose to have the same pattern as currently available in split(k)_test_score. However, it doesn't seem very user-friendly. I expect a user to be willing to know what happens inside a whole cv process, not having results grouped per cv split.

I would appreciate the validation of this technical choice before going on with writing more tests & docs.

Copy link

github-actions bot commented Oct 30, 2024

✔️ Linting Passed

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

Generated for commit: 179fba3. Link to the linter CI: here

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @MarieS-WiMLDS .

This looks good overall. It would need a changelog entry, as well as tests for the new feature.

Comment on lines 689 to 693
ranking(k) : ndarray of shape (n_subsets_of_features,)
The cross-validation ranking across (k)th fold.

support(k) : ndarray of shape (n_subsets_of_features,)
The cross-validation supports across (k)th fold.
Copy link
Member

Choose a reason for hiding this comment

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

would be nice to update this part of the docstring to mention when each key would exist here, since it depends on constructor arguments.

Also, the .. versionadded directives need to be there for each newly added key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the version, I didn't find anything in the docs (cf research). I wrote down a version by myself, but i'm unsure as I guess it's something automated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Furthermore, it seems that it doesn't appear anyway. If I take the example of n_features in the dict cv_results_, it doesn't appear in docs, while it's in the code.
Capture d’écran du 2024-11-26 16-19-26

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would be nice to update this part of the docstring to mention when each key would exist here, since it depends on constructor arguments.

I don't get this, it should appear all the time in the dict cv_results_ when RFECV is called, just as "split(k)_test_score" since it's built with the same process?

@adrinjalali adrinjalali changed the title feat(rfecv): add support and ranking for each cv and step FEAT rfecv: add support and ranking for each cv and step Nov 5, 2024
@adrinjalali
Copy link
Member

Tests are failing. Let me know if you need help on the PR.

@MarieSacksick
Copy link
Contributor Author

hi @adrinjalali, did you have a chance to get a new look please?

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Some nits, otherwise LGTM. Thanks @MarieS-WiMLDS

Comment on lines 679 to 687
split(k)_ranking : ndarray of shape (n_subsets_of_features,)
The cross-validation rankings across (k)th fold.

.. versionadded:: 1.7

split(k)_support : ndarray of shape (n_subsets_of_features,)
The cross-validation supports across (k)th fold.

.. versionadded:: 1.7
Copy link
Member

Choose a reason for hiding this comment

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

can we have links to a part of the user guide or an example where "ranking" and "support" are nicely explained? I don't find the intuitive enough for somebody who reads this the first time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found something for the ranking, but nothing for the support. I enriched the description.

@MarieSacksick MarieSacksick force-pushed the 17782_rfecv_provide_support_and_ranking branch from eaeb298 to 8b075cd Compare February 5, 2025 13:52
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.

LGTM. Thanks @MarieS-WiMLDS

@OmarManzoor OmarManzoor added the Waiting for Second Reviewer First reviewer is done, need a second one! label Feb 13, 2025
@adrinjalali adrinjalali enabled auto-merge (squash) April 23, 2025 12:37
@adrinjalali adrinjalali merged commit ec74b2a into scikit-learn:main Apr 23, 2025
36 checks passed
@MarieSacksick MarieSacksick deleted the 17782_rfecv_provide_support_and_ranking branch April 23, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:feature_selection Waiting for Second Reviewer First reviewer is done, need a second one!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFECV to provide the average ranking_ and support_
3 participants