train_test_split

museotoolbox.cross_validation.train_test_split(cv, X, y, random_state=False, **kwargs)[source]

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.

Parameters

Parameters

cvcross-validation function.

Allowed function from museotoolbox as scikit-learn.

Xarray-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.

yarray-like, of length n_samples

The target variable for supervised learning problems.

random_stateint, 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.

Examples

import numpy as np import museotoolbox as mtb

X, y = np.arange(10).reshape((5, 2)), range(5) cv = mtb.cross_validation.LeaveOneOut X_train, y_train, X_test, y_test = mtb.cross_validation.train_test_split(cv,X,y,random_state=42)

Examples using museotoolbox.cross_validation.train_test_split