backport of scikit-learn train_test_split cross-validation function for testing.