Skip to content
Prev 391095 / 398506 Next

How important is set.seed

So step 1 is not to compare models, rather to understand how the choice of seed influences final model output. Once you have a handle on this issue, then work at comparing models.
Tim

From: Neha gupta <neha.bologna90 at gmail.com>
Sent: Tuesday, March 22, 2022 12:19 PM
To: Bert Gunter <bgunter.4567 at gmail.com>
Cc: Ebert,Timothy Aaron <tebert at ufl.edu>; r-help at r-project.org
Subject: Re: [R] How important is set.seed

[External Email]
I read a paper two days ago (and that's why I then posted here about set.seed) which used interpretable machine learning.

According to the authors, different explanations (of the black-box models) will be produced by the ML models if different seeds are used or never used.
On Tue, Mar 22, 2022 at 5:12 PM Bert Gunter <bgunter.4567 at gmail.com<mailto:bgunter.4567 at gmail.com>> wrote:
OK, I'm somewhat puzzled by this discussion. Maybe I'm just clueless. But...

1. set.seed() is used to make any procedure that uses R's
pseudo-random number generator -- including, for example, sampling
from a distribution, random data splitting, etc. -- "reproducible".
That is, if the procedure is repeated *exactly,* by invoking
set.seed() with its original argument values (once!) *before* the
procedure begins, exactly the same results should be produced by the
procedure. Full stop. It does not matter how many times random number
generation occurs within the procedure thereafter -- R preserves the
state of the rng between invocations (but see the notes in ?set.seed
for subtle qualifications of this claim).

2. Hence, if no (pseudo-) random number generation is used, set.seed()
is irrelevant. Full stop.

3. Hence, if you don't care about reproducibility (you should! -- if
for no other reason than debugging), you don't need set.seed()

4. The "randomness" of any sequence of results from any particular
set.seed() arguments (including further calls to the rng) is a complex
issue. ?set.seed has some discussion of this, but one needs
considerable expertise to make informed choices here. As usual, we
untutored users should be guided by the expert recommendations of the
Help file.

*** If anything I have said above is wrong, I would greatly appreciate
a public response here showing my error.***

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Mar 22, 2022 at 7:48 AM Neha gupta <neha.bologna90 at gmail.com<mailto:neha.bologna90 at gmail.com>> wrote:

  
  
Message-ID: <BN6PR2201MB1553BCDEB5182D6A057C495CCF179@BN6PR2201MB1553.namprd22.prod.outlook.com>
In-Reply-To: <CA+nrPnusLd+pEb_rJVEzfsOb34B9_yMmhw=UtkEeyQbnp25R=w@mail.gmail.com>