Skip to content

Norm inconsistency between RFE and SelectFromModel #2121

Closed

Description

@jnothman

In each RFE iteration, the step features with the lowest importance are discarded. A similar thing happens in SelectFromModel (but selection is by threshold rather than by number of features). There are some inconsistencies:

  • the mixin admits either est.coef_ or est.feature_importances_ as the basis of its calculation; RFE only coef_ fixed in [MRG+1] Fix RFE #4496
  • the mixin uses np.abs(est.coef_), while RFE uses safe_sqr(est.coef_). The result is the same for selecting features by quantity, as long as coef_ is 1d, but where 2d, the sum is taken over axis 0, and the ordering under L1 and L2 norms may differ.

Should RFE support feature_importances_? For coef_.ndim == 2, should SelectFromModel use sqrt(sqr(coef_).sum(axis=0))?

(@glouppe, I think.)

Activity

  1. raghavrv commented on Jan 12, 2016

    @raghavrv
    Member

    @jnothman This is fixed in #4496? If so could you close this one?

  2. jnothman commented on Jan 12, 2016

    @jnothman
    MemberAuthor

    This is fixed in #4496?

    Part of it is. There's still the norm discrepancy, I think.

  3. changed the title [-]Inconsistencies between RFE and _LearntSelectorMixin[/-] [+]Norm inconsistencies between RFE and _LearntSelectorMixin[/+] on Jan 12, 2016
  4. changed the title [-]Norm inconsistencies between RFE and _LearntSelectorMixin[/-] [+]Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin)[/+] on Jan 12, 2016
  5. jnothman commented on Jan 12, 2016

    @jnothman
    MemberAuthor

    Perhaps now that SelectFromModel is a separate metaestimator, we could offer a choice of L1/L2 norm for 2d coefs.

  6. antoinewdg commented on Jan 12, 2016

    @antoinewdg
    Contributor

    Can I work on this one ?

  7. jnothman commented on Jan 12, 2016

    @jnothman
    MemberAuthor

    I'd be fine with that. I was considering knocking together a quick patch myself. I don't think it will be a much-used feature, but providing the option of consistency seems worthwhile.

    Please implement it to accept any numpy.linalg.norm setting, defaulting to the incumbent approach.

  8. changed the title [-]Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin)[/-] [+]Norm inconsistency between RFE and SelectFromModel[/+] on Jun 28, 2017
  9. jnothman commented on Jun 28, 2017

    @jnothman
    MemberAuthor

    We now have an option in SelectFromModel but not in RFE

  10. JanFidor commented on Feb 15, 2023

    @JanFidor
    Contributor

    Could I pick up this issue?

  11. haiatn commented on Aug 26, 2023

    @haiatn
    Contributor

    I see #6181 was merged is there anything more to do here or could this be completed?

  12. adrinjalali commented on Apr 17, 2024

    @adrinjalali
    Member

    @haiatn you've done some amazing triaging here. Thank you ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Easymodule:feature_selection

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions