train_test_split(cv, X, y, random_state=False, **kwargs)¶
Split arrays into random train and test subsets according to your choosen cross_validation method.
Quick utility that wraps input validation and next(ShuffleSplit().split(X, y)) and application to input data into a single call for splitting (and optionally subsampling) data in a oneliner.
cv (cross-validation function.) – Allowed function from museotoolbox as scikit-learn.
X (array-like, shape (n_samples, n_features), optional) – Training data, where n_samples is the number of samples and n_features is the number of features.
y (array-like, of length n_samples) – The target variable for supervised learning problems.
random_state (int, RandomState instance or None, optional (default=None)) – If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
import numpy as np import museotoolbox as mtb
X, y = np.arange(10).reshape((5, 2)), range(5) cv = mtb.cross_validation.LeaveOneOut(random_state=42) X_train, y_train, X_test, y_test = mtb.cross_validation.train_test_split(cv,X,y)