Ensemble ensemble = new Ensemble();
subLearner.setTreeWeight(treeWeight / bagCount);
for (int iteration = 1; iteration <= bagCount; iteration++) {
System.out.println("Iteration: " + iteration);
Sample subLearnerTrainSet = trainSet.getRandomSubSample(baggingTrainFraction, rnd);
//((TreeLearner) subLearner).setRnd();
Sample subLearnerOutOfTrainSet = trainSet.getOutOfSample(subLearnerTrainSet);
Sample subLearnerValidSet = (validSet == null || validSet.isEmpty() ? subLearnerOutOfTrainSet : validSet);
Ensemble subEnsemble = subLearner.learn(subLearnerTrainSet, subLearnerValidSet);
for (int t = 0; t < subEnsemble.getNumTrees(); t++) {
Tree tree = subEnsemble.getTreeAt(t);
double curTreeWeight = subEnsemble.getWeightAt(t);