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
(This is about the non-histogram-based version of GBDTs)
X is split into train and validation data with train_test_split(random_state=self.random_state).
As @johannfaouzi noted, in a warm starting context, this will produce a leak if If self.random_state is a RandomState instance: some samples that were used for training in a previous fit might be used for validation now.
I think the right fix would be to raise a ValueError if the provided random state isn't a number and early-stopping is activated
This should only be done when warm_start is true, though. So different calls to fit without warm start should probably use different splits if random state was None or a random state object.
At the end of the day, something has to be stored in order to generate the same training and validation sets. An integer is smaller than a tuple returned by get_state(), but the difference can probably be overlooked.
+1 for storing a seed as fit param and reuse that to seed an rng in fit only when warm_start=True.
AFAIK, np.random.RandomState accept uint32 seed only (between 0 and 2**32 - 1). So the correct way to get a seed from an existing random state object is:
Also instead of having _small_trainset_seed and _train_val_seed maybe we can just have one single seed. And I just realized that seed should also be passed to the binmapper that will also subsample.
Hmm this issue was about the non-histogram-based version of GBDTs, so #14999 did not do anything about this. I intentionally did not use keywords so that this issue would not be closed.
However I've just been starting working on a fix for this issue :)
Activity
NicolasHug commentedon Jun 7, 2019
After discussing with @amueller , maybe the best option would be to:
_train_val_split_seedthat would be generated once, the first timefitis calledrandom_stateparameter totrain_test_split().fitamueller commentedon Jun 7, 2019
This should only be done when warm_start is true, though. So different calls to
fitwithout warm start should probably use different splits if random state was None or a random state object.NicolasHug commentedon Jun 7, 2019
Right.
The problem is that we allow warm_start to be False the first time we fit, and later set it to true with
set_params:(amueller commentedon Jun 7, 2019
Sorry, we should always store the seed, but only re-use it if
warm_start=True.jnothman commentedon Jun 11, 2019
Why do you prefer to store a seed over
get_state()johannfaouzi commentedon Jun 11, 2019
At the end of the day, something has to be stored in order to generate the same training and validation sets. An integer is smaller than a tuple returned by
get_state(), but the difference can probably be overlooked.NicolasHug commentedon Jun 11, 2019
If we store a seed we can just directly pass it to
train_test_split, avoiding the need to create a new RandomState instance.both are fine with me.
ogrisel commentedon Sep 13, 2019
+1 for storing a seed as fit param and reuse that to seed an rng in fit only when
warm_start=True.AFAIK,
np.random.RandomStateacceptuint32seed only (between0and2**32 - 1). So the correct way to get a seed from an existing random state object is:johannfaouzi commentedon Sep 14, 2019
I did something that is not as good for HGBDT:
scikit-learn/sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py
Line 142 in 06632c0
It would probably be worth changing this as well.
I can work on this if there is no one.
NicolasHug commentedon Sep 15, 2019
PR welcome @johannfaouzi :)
Also instead of having
_small_trainset_seedand_train_val_seedmaybe we can just have one single seed. And I just realized that seed should also be passed to the binmapper that will also subsample.johannfaouzi commentedon Sep 19, 2019
Hmm this issue was about the non-histogram-based version of GBDTs, so #14999 did not do anything about this. I intentionally did not use keywords so that this issue would not be closed.
However I've just been starting working on a fix for this issue :)