First off, "ML models" do not all use random numbers (for prediction I
would guess very few of them do). Learn and pay attention to what the functions
you are using do.
Second, if you use random numbers properly and understand the precision that
your specific use case offers, then you don't need to use set.seed. However,
in practice, using set.seed can allow you to temporarily avoid chasing precision
gremlins, or set up specific test cases for testing code, not results. It is
your responsibility to not let this become a crutch... a randomized simulation
that is actually sensitive to the seed is unlikely to offer an accurate result.
Where to put set.seed depends a lot on how you are performing your simulations.
In general each process should set it once uniquely at the beginning, and if you
use parallel processing then use the features of your parallel processing
framework to insure that this happens. Beware of setting all worker processes to
use the same seed.
On March 21, 2022 5:03:30 PM PDT, Neha gupta <neha.bologna90 at gmail.com>
wrote:>Hello everyone
>
>I want to know
>
>(1) In which cases, we need to use set.seed while building ML models?
>
>(2) Which is the exact location we need to put the set.seed function i.e.
>when we split data into train/test sets, or just before we train a model?
>
>Thank you
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
Sent from my phone. Please excuse my brevity.