I am trying to implement kfold validation in python for the CIFAR-10 training set so for that i am trying to mask the the training set using a boolean list
X_Train_folds is an array of shape 5X1000X3072
selection = [True, True, True, True, True]
for k in k_choices:
for i in xrange(0,num_folds):
selection[i] = False
classifier = KNearestNeighbor()
classifier.train(X_train_folds[selection,:].reshape(1,X_train_folds.shape[0]*X_train_folds.shape[1])),
Y_train_folds[selection,:].reshape(1,Y_train_folds.shape[0]*Y_train_folds.shape[1]))
dists = classifier.compute_distances_no_loops(X_train_folds[i])
y_pred = classifier.predict_labels(dists, k)
num_correct = np.sum(y_pred == Y_train_folds[i])
accuracy = float(num_correct) / (y_train.shape[0]/num_folds)
k_to_accuracies[k] = accuracy
TypeError: list indices must be integers, not tuple
EDIT 1: The problem could be understood as i am trying to get like 4 rows except the ith one in the loop like if the array is [1,2,3,4,5] first i want a list of [2,3,4,5] then [1,3,4,5] and so on
If you want to just successively drop each i_th item in a list?