LeaveOneOut implements CrossValidator<ListDataset<INSTANCE>> { @Override public CrossValidationIterable<ListDataset<INSTANCE>> createIterable(ListDataset<INSTANCE> data) { return new LeaveOneOutIterable(data); }  @Override CrossValidationIterable<ListDataset<INSTANCE>> createIterable(ListDataset<INSTANCE> data); @Override String toString();  }
@Test public void test() { LeaveOneOut<Integer> cv = new LeaveOneOut<Integer>(); CrossValidationIterable<ListDataset<Integer>> iterable = cv.createIterable(dataset); int i = 0; for (ValidationData<ListDataset<Integer>> cvData : iterable) { ListDataset<Integer> training = cvData.getTrainingDataset(); ListDataset<Integer> validation = cvData.getValidationDataset(); assertEquals(1, validation.size()); assertEquals(dataset.size() - 1, training.size()); assertEquals(dataset.size(), validation.size() + training.size()); assertEquals(i, (int)validation.getInstance(0)); TIntHashSet set = new TIntHashSet(); for (int j=0; j<training.size(); j++) { set.add( training.getInstance(j) ); } assertEquals(training.size(), set.size()); assertFalse(set.contains(i)); for (int j=0; j<i; j++) assertTrue(set.contains(j)); for (int j=i+1; j<dataset.size(); j++) assertTrue(set.contains(j)); i++; } }