Fixed code, which generates sub-training set for building random forest