@Test public void testValidationCV() { DataModelIF<Long, Long> dm = DataModelFactory.getDefaultModel(); for (long u = 1L; u <= USERS; u++) { for (long i = 1L; i <= ITEMS; i++) { dm.addPreference(u, i, 1.0 * u * i); } } int nFolds = 5; DataModelIF<Long, Long>[] splits = new ValidationSplitter<>(new CrossValidationSplitter<Long, Long>(nFolds, false, 1L)).split(dm); assertTrue(splits.length == 3 * nFolds); long userTest = -1; long itemTest = -1; for (Long user : splits[2].getUsers()) { userTest = user; for (Long i : splits[2].getUserItems(user)) { itemTest = i; break; } break; } assertTrue(Double.isNaN(splits[0].getUserItemPreference(userTest, itemTest))); assertTrue(Double.isNaN(splits[1].getUserItemPreference(userTest, itemTest))); long userValid = -1; long itemValid = -1; for (Long user : splits[1].getUsers()) { userValid = user; for (Long i : splits[1].getUserItems(user)) { itemValid = i; break; } break; } assertTrue(Double.isNaN(splits[0].getUserItemPreference(userValid, itemValid))); assertTrue(Double.isNaN(splits[2].getUserItemPreference(userValid, itemValid))); }
private Split() { }
Split { private Split() { } }
Split { private Split() { } private  Split(); }
Split { private Split() { } private  Split(); static void main(final String[] args); }
Split { private Split() { } private  Split(); static void main(final String[] args);  }