sss = StratifiedShuffleSplit(y, n_iter=1, test_size=0.5, random_state=0)
len(sss)
for train_index, test_index in sss:
    print(('TRAIN:', train_index, 'TEST:', test_index))
X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]
Стратифицированное обучение/тестирование в scikit-learn