sklearn.cross_validation
.LabelShuffleSplit¶
-
class
sklearn.cross_validation.
LabelShuffleSplit
(labels, n_iter=5, test_size=0.2, train_size=None, random_state=None)[源代码]¶ Shuffle-Labels-Out cross-validation iterator
Provides randomized train/test indices to split data according to a third-party provided label. This label information can be used to encode arbitrary domain specific stratifications of the samples as integers.
For instance the labels could be the year of collection of the samples and thus allow for cross-validation against time-based splits.
The difference between LeavePLabelOut and LabelShuffleSplit is that the former generates splits using all subsets of size
p
unique labels, whereas LabelShuffleSplit generates a user-determined number of random test splits, each with a user-determined fraction of unique labels.For example, a less computationally intensive alternative to
LeavePLabelOut(labels, p=10)
would beLabelShuffleSplit(labels, test_size=10, n_iter=100)
.Note: The parameters
test_size
andtrain_size
refer to labels, and not to samples, as in ShuffleSplit.0.17 新版功能.
Parameters: labels : array, [n_samples]
Labels of samples
n_iter : int (default 5)
Number of re-shuffling and splitting iterations.
test_size : float (default 0.2), int, or None
If float, should be between 0.0 and 1.0 and represent the proportion of the labels to include in the test split. If int, represents the absolute number of test labels. If None, the value is automatically set to the complement of the train size.
train_size : float, int, or None (default is None)
If float, should be between 0.0 and 1.0 and represent the proportion of the labels to include in the train split. If int, represents the absolute number of train labels. If None, the value is automatically set to the complement of the test size.
random_state : int or RandomState
Pseudo-random number generator state used for random sampling.