if (getInputFormat() == null) {
throw new IllegalStateException("No input instance format defined");
}
Instances input = getInputFormat();
input.sort(0); // make sure that bagID is sorted
Instances output = getOutputFormat();
Instances bagInsts = output.attribute(1).relation();
Instance inst = new Instance(bagInsts.numAttributes());
inst.setDataset(bagInsts);