1. Home
  2. Data Science
  3. Scikit-learn
  4. What does setting random_state in train_test_split…

Added 30 Nov -0001

What does setting random_state in train_test_split guarantee?

  1. The rows are shuffled in place, so the original DataFrame's order is permanently changed
  2. The same split is produced on repeated runs with the same inputs and library version Correct answer
  3. Every run is statistically independent, so no split pattern can ever repeat itself
  4. The split is stratified automatically, keeping class proportions in both partitions

Correct answer

B. The same split is produced on repeated runs with the same inputs and library version

15 views

MCQSEXAM

Explanation

random_state seeds the internal pseudo-random generator, so with identical data and library version the same permutation and the same train/test rows come back, which makes experiments reproducible. It does not make splits independent, and a different pandas or NumPy version may change the sampling path. For class balance, stratify=y is what preserves proportions.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs