What is “random-state” in sklearn.model_selection.train_test_split example? [duplicate]

Isn’t that obvious? 42 is the Answer to the Ultimate Question of Life, the Universe, and Everything.

On a serious note, random_state simply sets a seed to the random generator, so that your train-test splits are always deterministic. If you don’t set a seed, it is different each time.

Relevant documentation:

random_state : int, RandomState instance or None, optional
(default=None)

If int, random_state is the seed used by the random
number generator; If RandomState instance, random_state is the random
number generator; If None, the random number generator is the
RandomState instance used by np.random.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)