Skip to content

RFC: DecisionTree*/ExtraTree*: why accepting a splitter parameter? (let's deprecate it) #33158

Open

Description

@cakedev0

Classes DecisionTree* and ExtraTree* are exact copies, the only thing that differentiates them is the default value of the splitter parameter.

I think it's confusing to expose this parameter in the public API, I think DecisionTree*s should always use the "best-splitter" and ExtraTree* should always use the random-splitter.

Why I think it's confusing: because for instance a ExtraTreeRegressor(splitter="best") is absolutely not "An extremely randomized tree regressor" as the doc describes this model. It's just a normal DecisionTreeRegressor(). I was confused about that for a long time, I though that somehow this would still have some randomness in it / a different behavior from a decision tree. I understood it was not the case only by looking at the code.

I suspect this parameter exists for historical reasons: at one point in the past it seems that trees accepted custom splitters. But it's not the case anymore:

_parameter_constraints: dict = {
    "splitter": [StrOptions({"best", "random"})],
    ...
}

Side node: we could also remove some code that handles the case of a custom splitter (see #33150), and the code that allows Splitter subclasses to be serializable (__reduce__, etc.).

What do you think?

Activity

  1. added
    Needs Triage
    on Jan 30, 2026
  2. betatim commented on Feb 3, 2026

    @betatim
    Member

    I think removing the argument from ExtraTreeClassifier and ExtraTreeRegressor makes sense. Changing the value of splitter doesn't make sense for this class.

    However, right now ExtraTree* inherits from DecisionTree* and passes splitter="random" to the constructor. If we remove this constructor argument from DecisionTree* we lose the ability to have this convenient way of making an ExtraTree*. In addition I think it is fine (if a bit strange) for a user to dt = DecisionTreeClassifier(splitter="random").

    Why I think it's confusing: because for instance a ExtraTreeRegressor(splitter="random") is absolutely not "An extremely randomized tree regressor" as the doc describes this model.

    I think there is a typo here, did you mean ExtraTreeRegressor(splitter="best")?

  3. removed
    Needs Triage
    on Feb 3, 2026
  4. cakedev0 commented on Feb 3, 2026

    @cakedev0
    MemberAuthor

    Oops, typo indeed 😅 Fixed it.

    If we remove this constructor argument from DecisionTree* we lose the ability to have this convenient way of making an ExtraTree*

    I think it should be possible to find a convenient way to share the code that can be shared without keeping the splitter parameter for DecisionTree*, but I haven't tried.

  5. betatim commented on Feb 3, 2026

    @betatim
    Member

    Even if we can find a way to avoid the inheritance thing, I think it is a valid use case for a user to "reconfigure" DecisionTree*via the splitter argument. So I'd keep it for decision tree.

  6. cakedev0 commented on Mar 5, 2026

    @cakedev0
    MemberAuthor

    Linking PR discussion here: #32119 (comment). This is a small details that differ between DecisionTree* and ExtraTree* (but for nor apparent reason).

    Btw, @lorentzenchr I'd love to hear your opinion on this issue 🙏

  7. lorentzenchr commented on Mar 5, 2026

    @lorentzenchr
    Member

    I am a bit undecided between:

    1. Deprecate ExtraTree*, it is 100% redundant.
    2. Deprecate the splitter parameter.
      Implementation: We already have BaseDecisionTree and even DecisionTreeClassifier does almost nothing new on top of it.
  8. cakedev0 commented on Mar 5, 2026

    @cakedev0
    MemberAuthor

    Hum, I didn't thought about the option "Deprecate ExtraTree*" but why not indeed.

    I made a quick search on github search, and I saw more DecisionTree*(splitter="random") in normal-looking DS/ML projects than ExtraTree*s, so it will probably be less of an inconvenience for most users to deprecate ExtraTree*.

  9. lorentzenchr commented on Mar 5, 2026

    @lorentzenchr
    Member

    Be aware that, from experience, I am easier persuaded for a deprecation than other core devs.

  10. thariq-nugrohotomo commented on Mar 14, 2026

    @thariq-nugrohotomo

    +1 for deprecating tree.ExtraTree*.

    Today I spent some time trying to find out the differences between DecisionTree* v.s. ExtraTree*, thinking that there is some fundamental differences why ExtraTree* cannot be replaced by DecisionTree* with random split and adjusted max_features.
    I hope to discover this thread first before anything else.

    There are some people in the same boat as me =

    1. https://www.kaggle.com/discussions/questions-and-answers/427411
    2. https://stackoverflow.com/questions/20177970/decisiontreeclassifier-vs-extratreeclassifier
  11. lorentzenchr commented on Mar 14, 2026

    @lorentzenchr
    Member

    One reason to have them both is for easier discoverability. For instance, we have LinearRegression, Ridge, Lasso and ElasticNet. In principle, all do the same with different parameters. But this way, if you web search, it is easier to find. Same for ExtraTree*.

  12. cakedev0 commented on Mar 16, 2026

    @cakedev0
    MemberAuthor

    Thanks @thariq-nugrohotomo, this clearly shows this is confusing and that we need to do something about it, at the very least documentation (e.g. a note in the splitter parameter docstring about equivalence with DecisionTree*/ExtraTree* if you change it to non default value).

  13. AnneBeyer commented on Jun 2, 2026

    @AnneBeyer
    Member

    Going through the docs a bit, I'm in favour of deprecating ExtraTreeClassifier/Regressor.

    The docstrings of both say

    Warning: Extra-trees should only be used within ensemble methods.

    and we do have the ensemble versions ExtraTreesClassifier/Regressor (note the s).
    From what I understand, in these, we should be able to substitute the ExtraTree template with the corresponding DecisionTree template (note that estimators_ is already described using the latter):

    estimator_ : :class:`~sklearn.tree.ExtraTreeClassifier`
    The child estimator template used to create the collection of fitted
    sub-estimators.
    .. versionadded:: 1.2
    `base_estimator_` was renamed to `estimator_`.
    estimators_ : list of DecisionTreeClassifier
    The collection of fitted sub-estimators.

    In the documentation, ExtraTreeClassifier/Regressor is actually only mentioned in the section on Missing Values Support (before, there are only references to the splitter attribute in the sections for Complexity and Mathematical Formulation), and I think this can be reformulated in terms of parameters as well.

    I might still be missing things, but currently I don't see any added value (and, as noted above, only unnecessary confusion) in keeping those two.

  14. cakedev0 commented on Jun 2, 2026

    @cakedev0
    MemberAuthor

    (I was writting this when I read @AnneBeyer message above, I'm happy to see we reached the same conclusion, and for similar reasons 😄👌)

    #33568 is one more proof that people are confused by this.

    Let's try to move forward. For now, 4 options have been proposed:

    1. just adding doc, see PR: DOC Clarify ExtraTree splitter behavior #34183
    2. deprecating splitter in ExtraTree* but not in DecisionTree*. I think this alone is not enough to avoid confusion and doc is also needed.
    3. deprecating splitter in both ExtraTree* and DecisionTree*
    4. deprecating/removing the classes ExtraTree*.

    IMO, options 1 and 2 puts too much responsability/cognitive load on the user, and they don't solve well enough the issue.

    I personally vote for 4:
    + It reduces the amount of information users have to understand for the same functionalities
    + It reduce the amount of code sklearn/tree/_classes.py
    + It allows cleaner testing/avoids redundant testing.
    + It fixes #34180 for free ;)
    - It hurts a bit discoverability, be we still have ExtraTrees* (with an s), which I think is the name people look for most of the time (their pages get 4x more visits than their ExtraTree* siblings).
    - It's not aligned with what is done for trees ensemble (RandomForest* and ExtraTrees* with no splitter param)

    My second choice is 3:
    + It reduces the amount of information users have to understand for the same functionalities
    + It's aligned with what is done for trees ensemble
    + It allows cleaner testing/avoids redundant testing.
    - It probably requires more redundancy in the code and more changes, which might conflict a bit painfully with some other PRs.
    - Transition in the doc will be harder (we mention "splitter best/random" in quite a few places).
    - It's a bit less convenient for users than being able to switch the splitter param.

    But we can still merge the doc PR while waiting for a decision here.

  15. AnneBeyer commented on Jun 3, 2026

    @AnneBeyer
    Member

    I agree that we should merge #33150 and #34183 as a start. If we decide to go for the deprecation, it will need some more rephrasing and code clean-up, but these already add a bit more clarity in the meantime.

  16. cakedev0 commented on Jun 12, 2026

    @cakedev0
    MemberAuthor

    Quick IRL with @ogrisel confirmed this direction (removing deprecating/removing the classes ExtraTree*). @ogrisel do you confirm after reading some more context in this issue?

  17. ogrisel commented on Jun 12, 2026

    @ogrisel
    Member

    I agree I am fine with deprecating the redundant ExtraTree{Classifier,Regressor} classes, especially since we received feedback from confused users at several occasions and I agree with the assessment in #33158 (comment).

    Note that, this deprecation and then removal will force us to change the type of the trees stored in the estimators_ attribute of the ExtraTreesClassifier/ExtraTreesRegressor ensemble objects. As a consequence, pickled ensembles of extra trees from an older version of scikit-learn will not be loadable anymore, but this was explicitly never guaranteed in our doc.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions