Skip to content

RFC feature subsampling for tree based models #27347

Closed

Description

@lorentzenchr

Background

Currently, our (mostly tree-based) models supporting feature subsampling via max_features are:

  • DecisionTreeClassifier, DecisionTreeRegressor
  • ExtraTreeClassifier, ExtraTreeRegressor
  • BaggingClassifier, BaggingRegressor
  • ExtraTreesClassifier, ExtraTreesRegressor
  • GradientBoostingClassifier, GradientBoostingRegressor
  • IsolationForest
  • RandomForestClassifier, RandomForestRegressor

Soon, HistGradientBoostingClassifier and HistGradientBoostingRegressor will have feature subsampling, too, see #27139.

Problem Statement

max_features can be a float between 0 and 1. In this case, it means that a fraction of features is randomly selected in each split. It can also be an integer, in which case it specifies the number of features selected in each split.
This means that 1 and 1. have very different effects! See #27139 (review).

Also note that for most estimators the default is max_features=None or 1.0 meaning no subsampling. The notable exception is RandomForestClassifier and ExtraTreesClassifier with default max_features="sqrt" (which makes sense), but the corresponding regressors still use all features (so no rf but bagged trees). This was discussed in detail in #20111.

Additionally, for most estimator it means subsampling per tree split/node. For BaggingC/R models and IsolationForest it means per model/iteration.

Proposal

Accompanied with a proper deprecation strategy, we could add different arguments, one for specifying fractions, one for integer numbers.

Decision Options

A Do we want to change the current situation?

B Which names shall the new arguments have?

B.1

We could keep max_features for number of features and add only one new argument for fractions. Or we can actually add 2 new arguments and deprecate max_features completely.

B.2

Possible names for fractions, see also #27139 (comment):

  • colsample_bynode, same name as in XGBoost and LightGBM
  • feature_(sub)sample_per_split
  • feature_fraction_per_split

@scikit-learn/core-devs

Activity

  1. added
    Needs Triage
    on Sep 12, 2023
  2. adrinjalali commented on Sep 13, 2023

    @adrinjalali
    Member

    I personally don't see an issue with the current semantics of the parameter. So I wouldn't bother changing or adding a new parameter.

  3. added
    Needs Triage
    and removed
    Needs Triage
    on Sep 20, 2023
  4. betatim commented on Sep 20, 2023

    @betatim
    Member

    An interesting thing to know, that I don't know how to find out, is how often someone uses max_features=1. when they meant to use max_features=1. This seems like the only(?) case where a user would not get what they wanted and it might be a bit tricky to track down why.

    If this mistake doesn't happen a lot, then maybe nothing is broken/needs fixing/changing?

    The code in scikit-learn itself would be simpler if we changed this, but I'm not sure if making our lives easier is a big enough reason to change?

  5. removed
    Needs Triage
    on Sep 21, 2023
  6. added this to the 1.4 milestone on Sep 25, 2023
  7. modified the milestones: 1.4, 1.5 on Dec 4, 2023
  8. ogrisel commented on Dec 4, 2023

    @ogrisel
    Member

    Moving this discussion to 1.5 as I don't think we will reach a consensus for 1.4.

  9. adrinjalali commented on Jan 4, 2024

    @adrinjalali
    Member

    Should we be closing this one @lorentzenchr ?

  10. lorentzenchr commented on Jan 4, 2024

    @lorentzenchr
    MemberAuthor

    A Do we want to change the current situation?

    The answer seems to be NO.

  11. JohnKilbride commented on Aug 22, 2024

    @JohnKilbride

    Given the conversation in #20111, I'm not clear why the default value of the RandomForestRegressor is set to use all features.

    Using all features would make it a bagged ensemble of decision trees so the function name is actively misleading.

    This seems liable to trip up beginners who may not be familiar with the details of the implementation or those coming from languages like R where the default value is something like sqrt(p) or p/3.

    I don't particularly care what the subsampling fraction is set as. As show in the discussion I posted, there are many candidates and it is ultimately problem dependent. I just think that that some subsampling should be performed by default as it is basically one of the two defining features of the RandomForest algorithm.

  12. lorentzenchr commented on Aug 23, 2024

    @lorentzenchr
    MemberAuthor

    Given the conversation in #20111, I'm not clear why the default value of the RandomForestRegressor is set to use all features.

    It is for historical reasons. I'm bothered by that situation myself.
    @JohnKilbride It is best if you comment directly on #20111 and express your opinion, and then tell as many people as you can to do the same.

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions