Skip to content
Snippets Groups Projects
Commit 2e49fbe9 authored by Gael Varoquaux's avatar Gael Varoquaux
Browse files

MISC: Cosmit (cosmetic commit): s/label/labels, because it is a list.


git-svn-id: https://scikit-learn.svn.sourceforge.net/svnroot/scikit-learn/trunk@655 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8
parent 1c2aa644
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment