With imbalanced data, say 5% fraud, a random split can leave the test set with almost no positives. A stratified split keeps each class's proportion the same in train and test.
Implement stratified_split(y, test_size=0.2, seed=0) returning (train_idx, test_idx) as sorted NumPy integer arrays:
rng = np.random.default_rng(seed), calling rng.permutation once per class in class order.round(n_class * test_size) shuffled indices in the test set and the rest in train. Python's round is fine.