@Test public void testBagging() { Data bag = classifierData.bagging(rng); assertEquals(classifierData.size(), bag.size()); boolean found = false; for (int index = 0; index < classifierData.size() && !found; index++) { found = !bag.contains(classifierData.get(index)); } assertTrue("some instances from data should not be in the bag", found); bag = regressionData.bagging(rng); assertEquals(regressionData.size(), bag.size()); found = false; for (int index = 0; index < regressionData.size() && !found; index++) { found = !bag.contains(regressionData.get(index)); } assertTrue("some instances from data should not be in the bag", found); }
public Data bagging(Random rng) { int datasize = size(); List<Instance> bag = new ArrayList<>(datasize); for (int i = 0; i < datasize; i++) { bag.add(instances.get(rng.nextInt(datasize))); } return new Data(dataset, bag); }
Data implements Cloneable { public Data bagging(Random rng) { int datasize = size(); List<Instance> bag = new ArrayList<>(datasize); for (int i = 0; i < datasize; i++) { bag.add(instances.get(rng.nextInt(datasize))); } return new Data(dataset, bag); } }
Data implements Cloneable { public Data bagging(Random rng) { int datasize = size(); List<Instance> bag = new ArrayList<>(datasize); for (int i = 0; i < datasize; i++) { bag.add(instances.get(rng.nextInt(datasize))); } return new Data(dataset, bag); } Data(Dataset dataset);  Data(Dataset dataset, List<Instance> instances); }
Data implements Cloneable { public Data bagging(Random rng) { int datasize = size(); List<Instance> bag = new ArrayList<>(datasize); for (int i = 0; i < datasize; i++) { bag.add(instances.get(rng.nextInt(datasize))); } return new Data(dataset, bag); } 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(); }
Data implements Cloneable { public Data bagging(Random rng) { int datasize = size(); List<Instance> bag = new ArrayList<>(datasize); for (int i = 0; i < datasize; i++) { bag.add(instances.get(rng.nextInt(datasize))); } return new Data(dataset, bag); } 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();  }