Data implements Cloneable { public Data rsplit(Random rng, int subsize) { List<Instance> subset = Lists.newArrayListWithCapacity(subsize); for (int i = 0; i < subsize; i++) { subset.add(instances.remove(rng.nextInt(instances.size()))); } return new Data(dataset, subset); } Data(Dataset dataset);  Data(Dataset dataset, List<Instance> instances); int size(); boolean isEmpty(); boolean contains(Instance v); Instance get(int index); Data subset(Condition condition); Data bagging(Random rng); Data bagging(Random rng, boolean[] sampled); Data rsplit(Random rng, int subsize); boolean isIdentical(); boolean identicalLabel(); double[] values(int attr); @Override Data clone(); @Override boolean equals(Object obj); @Override int hashCode(); double[] extractLabels(); int majorityLabel(Random rng); void countLabels(int[] counts); Dataset getDataset();  }
@Test public void testRsplit() { Data source = classifierData.clone(); Data subset = source.rsplit(rng, 0); assertTrue("subset should be empty", subset.isEmpty()); assertEquals("source.size is incorrect", DATA_SIZE, source.size()); source = classifierData.clone(); subset = source.rsplit(rng, DATA_SIZE); assertEquals("subset.size is incorrect", DATA_SIZE, subset.size()); assertTrue("source should be empty", source.isEmpty()); int subsize = rng.nextInt(DATA_SIZE); source = classifierData.clone(); subset = source.rsplit(rng, subsize); assertEquals("subset.size is incorrect", subsize, subset.size()); assertEquals("source.size is incorrect", DATA_SIZE - subsize, source.size()); source = regressionData.clone(); subset = source.rsplit(rng, 0); assertTrue("subset should be empty", subset.isEmpty()); assertEquals("source.size is incorrect", DATA_SIZE, source.size()); source = regressionData.clone(); subset = source.rsplit(rng, DATA_SIZE); assertEquals("subset.size is incorrect", DATA_SIZE, subset.size()); assertTrue("source should be empty", source.isEmpty()); subsize = rng.nextInt(DATA_SIZE); source = regressionData.clone(); subset = source.rsplit(rng, subsize); assertEquals("subset.size is incorrect", subsize, subset.size()); assertEquals("source.size is incorrect", DATA_SIZE - subsize, source.size()); }