You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
@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.
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.
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.
Activity
vachanda commentedon Oct 31, 2019
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.
qinhanmin2014 commentedon Oct 31, 2019
Yes, something like xgb/lgb/ctb. Be careful, there's only +1 from me (we need +2 before making the decision)
NicolasHug commentedon Nov 17, 2019
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 ;)
candalfigomoro commentedon Aug 17, 2021
@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.
ogrisel commentedon Oct 29, 2021
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.
fPkX6F1nGTX commentedon Dec 20, 2021
How about joining forces with https://github.com/keras-team/keras and/or folding into tensorflow?
vedranf commentedon Mar 19, 2023
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:
results in somewhat expected:
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.
lorentzenchr commentedon Aug 3, 2023
Let‘s centralize the discussion and join #18748.