impliment random_forest algorithm with bagging and stopping function