Contents

scikits.learn.cross_val.LeavePLabelOut

class scikits.learn.cross_val.LeavePLabelOut(labels, p)

Leave-P-Label_Out cross-validation iterator: Provides train/test indexes to split data in train test sets

__init__(labels, p)

Leave-P-Label_Out cross validation: Provides train/test indexes to split data in train test sets

Parameters :

labels : list

List of labels

Examples

>>> from scikits.learn import cross_val
>>> X = [[1, 2], [3, 4], [5, 6]]
>>> y = [1, 2, 1]
>>> labels = [1, 2, 3]
>>> lpl = cross_val.LeavePLabelOut(labels, p=2)
>>> len(lpl)
3
>>> print lpl
scikits.learn.cross_val.LeavePLabelOut(labels=[1, 2, 3], p=2)
>>> for train_index, test_index in lpl:
...    print "TRAIN:", train_index, "TEST:", test_index
...    X_train, X_test, y_train, y_test = cross_val.split(train_index,             test_index, X, y)
...    print X_train, X_test, y_train, y_test
TRAIN: [False False  True] TEST: [ True  True False]
[[5 6]] [[1 2]
 [3 4]] [1] [1 2]
TRAIN: [False  True False] TEST: [ True False  True]
[[3 4]] [[1 2]
 [5 6]] [2] [1 1]
TRAIN: [ True False False] TEST: [False  True  True]
[[1 2]] [[3 4]
 [5 6]] [1] [2 1]