How to recursively train Treebagger preserving the information from one train data set to another one ?

I would like to make cross validation, for a Random Forest model, "by hand". So once I split my data into kfolds, I have to recursively train TreeBagger (https://it.mathworks.com/help/stats/treebagger.html) and then test it on one of these folds. Would it make sense to train the TreeBagger for each fold ? If I train on one train set and then I train on another one without preserving any memory of the previous training, it is like training it on just one train set... so how to recursively train Treebagger preserving the information from one train data set to another one ?

Answers (1)

I don't understand what you specifically mean by "recursively" in this context.
The closest idea I can think of to what you mean for "by hand" would be to use the cvpartition function to define the folds manually, and then train on a subset of folds, then test on the folds that were not used for training.

Asked:

on 22 Jan 2026

Answered:

on 23 Jan 2026

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!