@Test
public void testSubset() {

  int n = 10;
  for (int nloop = 0; nloop < n; nloop++) {
    int attr = rng.nextInt(classifierData.getDataset().nbAttributes());
    double[] values = classifierData.values(attr);
    double value = values[rng.nextInt(values.length)];
    Data eSubset = classifierData.subset(Condition.equals(attr, value));
    Data lSubset = classifierData.subset(Condition.lesser(attr, value));
    Data gSubset = classifierData.subset(Condition.greaterOrEquals(attr, value));
    for (int index = 0; index < DATA_SIZE; index++) {
      Instance instance = classifierData.get(index);
      if (instance.get(attr) < value) {
        assertTrue(lSubset.contains(instance));
        assertFalse(eSubset.contains(instance));
        assertFalse(gSubset.contains(instance));
      } else if (instance.get(attr) == value) {
        assertFalse(lSubset.contains(instance));
        assertTrue(eSubset.contains(instance));
        assertTrue(gSubset.contains(instance));
      } else {
        assertFalse(lSubset.contains(instance));
        assertFalse(eSubset.contains(instance));
        assertTrue(gSubset.contains(instance));
      }
    }
    // regression
    attr = rng.nextInt(regressionData.getDataset().nbAttributes());
    values = regressionData.values(attr);
    value = values[rng.nextInt(values.length)];
    eSubset = regressionData.subset(Condition.equals(attr, value));
    lSubset = regressionData.subset(Condition.lesser(attr, value));
    gSubset = regressionData.subset(Condition.greaterOrEquals(attr, value));
    for (int index = 0; index < DATA_SIZE; index++) {
      Instance instance = regressionData.get(index);
      if (instance.get(attr) < value) {
        assertTrue(lSubset.contains(instance));
        assertFalse(eSubset.contains(instance));
        assertFalse(gSubset.contains(instance));
      } else if (instance.get(attr) == value) {
        assertFalse(lSubset.contains(instance));
        assertTrue(eSubset.contains(instance));
        assertTrue(gSubset.contains(instance));
      } else {
        assertFalse(lSubset.contains(instance));
        assertFalse(eSubset.contains(instance));
        assertTrue(gSubset.contains(instance));
      }
    }
  }
}