diff --git a/scikits/learn/utils/crossval.py b/scikits/learn/utils/crossval.py index b4704c4470f57db5861e9b4183ee14d824213cd8..0669e0e2c2a2233bf25a2e5c0fdbc9a949523370 100644 --- a/scikits/learn/utils/crossval.py +++ b/scikits/learn/utils/crossval.py @@ -3,8 +3,6 @@ # $Id$ -import exceptions - import numpy as np try: @@ -136,14 +134,14 @@ def k_fold(n, k): yield train_index, test_index -def leave_one_label_out(label): +def leave_one_label_out(labels): """ Leave-One-Label_Out cross validation: Provides train/test indexes to split data in train test sets Parameters ---------- - label : list + labels : list List of labels Examples @@ -152,8 +150,8 @@ def leave_one_label_out(label): >>> from scikits.learn.utils import crossval >>> X = [[1, 2], [3, 4], [5, 6], [7, 8]] >>> y = [1, 2, 1, 2] - >>> label = [1,1,2,2] - >>> lol = crossval.leave_one_label_out(label) + >>> labels = [1, 1, 2, 2] + >>> lol = crossval.leave_one_label_out(labels) >>> for train_index, test_index in lol: ... print "TRAIN:", train_index, "TEST:", test_index ... X_train, X_test, y_train, y_test = crossval.split(train_index, \ @@ -169,9 +167,9 @@ def leave_one_label_out(label): [7 8]] [1 2] [1 2] """ - for i in np.unique(label): - test_index = np.zeros(len(label), dtype=np.bool) - test_index[label==i] = True + for i in np.unique(labels): + test_index = np.zeros(len(labels), dtype=np.bool) + test_index[labels==i] = True train_index = np.logical_not(test_index) yield train_index, test_index