# Number of Samples per-Tree in a Random Forest

1. How many samples does each tree of a random forest use to train in sci-kit learn the implementation of Random Forest Regression?

2. And, how does the number of samples change when the bootstrap option is on compared to when it’s off?

In “Random Forest” by Breiman, I believe he mentions that each tree is trained on 1/3 of the data. Is that the case in the implementation of scikit learn as well?

I am answering my question. I got a chance to talk to the people who implemented the random forest in sci-kit learn. Here is the explanation:

"If bootstrap=False, then each tree is built on all training samples.

If bootstrap=True, then for each tree, N samples are drawn randomly with replacement from the training set and the tree is built on this new version of the training data. This introduces randomness in the training procedure since trees will each be trained on slightly different training sets. In expectation, drawing N samples with replacement from a dataset of size N will select ~2/3 unique samples from the original set. "

From Scikit Learn v0.22, you can still use boostraping but limit the maximum number of samples each tree is trained on (max_samples of RandomForestRegressor class).

Excellent sources on this subject for more details:

• But how do you set the sample size for each tree to be trained on? – verkter Sep 11 '19 at 22:32
• Here's something weird: the default max_sample value is X.shape[0], i.e., the whole dataset. I'm contacting their forum to figure out why is being used as default the whole dataset. – Fernando Wittmann May 8 '20 at 21:20
• sorry, I'm not clear on your question. Usually, X.shape[0] should be your total number of samples. Bootstrapping is usually sampling with replacement where the unique number of samples can be estimated as explained above. So by default: the bag size of your sampling with replacement = X.shape[0] = total number of samples – sinapan May 8 '20 at 23:36