if (selected == null) {
selected = new boolean[data.getDataset().nbAttributes()];
}
if (data.isEmpty()) {
return new Leaf(-1);
}
if (isIdentical(data)) {
return new Leaf(data.majorityLabel(rng));
}
if (data.identicalLabel()) {
return new Leaf(data.get(0).getLabel());
}
int[] attributes = randomAttributes(rng, selected, m);
if (attributes == null || attributes.length == 0) {
// we tried all the attributes and could not split the data anymore
return new Leaf(data.majorityLabel(rng));
}
// find the best split
Split best = null;
for (int attr : attributes) {