Problem 2: Reproducible Split with random_state
Easypython
Learn the Concept: Train-Test SplitProblem Description
Write a Python program that performs the same train-test split twice using the same random_state, and confirms both splits produce identical results.
Input
A dataset with features (X) and a label (y).
Output
A confirmation that both splits are identical.
Constraints
- Use the same
random_statevalue both times.
Example Input
textX, y, random_state=42
Example Output
textSplits are identical: True
Concepts Covered
random_state, reproducibility, array comparison.
Related Problems
- Problem 1: Basic Train-Test SplitEasy · pythonSolve Problem
- Problem 3: Stratified Split for Imbalanced ClassesEasy · pythonSolve Problem
- Problem 4: Split Then Scale CorrectlyEasy · pythonSolve Problem