Skip to content

GBDT support custom validation set #15127

Closed

Description

@qinhanmin2014

Is it reasonable to support custom validation set in GBDT? Currently we do train_test_split internally but I think sometimes users want to do train_test_split themselves (e.g., sometimes we want to use first 80% of the dataset as training set and the rest of the dataset as validation set.).
xgboost, lightgbm and catboost all support custom validation set.

Activity

  1. vachanda commented on Oct 31, 2019

    @vachanda
    Contributor

    Hi @qinhanmin2014, just to clarify you are talking about the BaseHistGradientBoosting class where the validation split is taking place?

    P.S. I want to work on this and just needed the clarification.

  2. qinhanmin2014 commented on Oct 31, 2019

    @qinhanmin2014
    MemberAuthor

    Hi @qinhanmin2014, just to clarify you are talking about the BaseHistGradientBoosting class where the validation split is taking place?

    Yes, something like xgb/lgb/ctb. Be careful, there's only +1 from me (we need +2 before making the decision)

  3. NicolasHug commented on Nov 17, 2019

    @NicolasHug
    Member

    This could be used for any estimator that implements early stopping, not just the GBDTs.

    What would the API look like? New arguments to fit? How does that work out in a pipeline? Or in general for the meta estimators?

    Clearly that's not a trivial decision / design ;)

  4. candalfigomoro commented on Aug 17, 2021

    @candalfigomoro

    @NicolasHug @TomDLT
    The current validation set approach of scikit-learn tempts people to produce bad models. Suppose you perform a minority class oversampling or data augmentation or some other preprocessing step. Ideally, the validation set should reflect the distribution of the test set and live data. If you split the validation set from the training set, you could inherit a biased distribution from the training set. Splitting a validation set from the training set is often a bad practice.

  5. ogrisel commented on Oct 29, 2021

    @ogrisel
    Member

    That's a very good point. Assuming the features are preprocessed by a pipeline, that would make the API complex quite complex to get right. For instance, assume that scikit-learn had a rebalancing meta-estimator (such as BalancedBagging* in imbalanced-learn) to wrap the GBDT model, it means that validation set need to be computed using the upstream steps of the pipeline, before the meta-estimator that wraps the GBDT model.

    I don't think it's possible or desirable to have an API to handle this methodological point automagically. But we should definitely make it possible to pass this kind a pre-computed validation set and have an example to document this kind of pipelines.

  6. fPkX6F1nGTX commented on Dec 20, 2021

    @fPkX6F1nGTX
  7. vedranf commented on Mar 19, 2023

    @vedranf

    I tried to setup a grid search with GBDT from scikit-learn and XGBoost (using the custom validation set) in order to compare them. However, passing eval set in fit:

    grid.fit(X, y, groups=groups, clf__eval_set=[...])
    

    results in somewhat expected:

    TypeError: fit() got an unexpected keyword argument 'eval_set'
    

    so I could only use either GBDT or XGBoost in grid search, but not both estimators in the same run. Perhaps as part of this issue, first step would be to allow the "eval_set" in kwargs, even if it won't (yet) be used internally for early stopping so that one can at least directly compare XGBoost models with ones in scikit-learn.

  8. lorentzenchr commented on Aug 3, 2023

    @lorentzenchr
    Member

    Let‘s centralize the discussion and join #18748.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions