PDA

View Full Version : cross validation



mickey
14th September 2009, 17:39
Hello,
in Java I need to split a list and generate a TEST and TRAINING set list; I did this below that doesn't work because of an exception during of the 'removeAll'; is it a good way to do it? how can I do that RemoveALL? thanks


File dir = new File("..\\..\\dir");
String[] files = dir.list();
int block = files.length*9/10;
for (int numbOfTest=0; numbOfTest < 10; numbOfTest++ ) {
List<String> list = Arrays.asList(files);
List<String> listTEST = list.subList( numbOfTest*block, block);
Collection<String> c = listTEST;
//now list will be the training list
list.removeAll( list ); //error