# Random Forest, dependent measurements

I have a following quiz:

A random forest is used for classifying the disease state of patients based on measuring multiple genes. The dataset consists of 100 genes and 50 patients. However, for each patient, 10 measurements exist at different time points.

When analyzing the data, the out-of-bag error is very close to the error on the training data, but very different from the error on the test dataset.

I am not quite sure if I understand it correctly. The out-of-bag error is calculated on the points (patients) that were not included during bootstrapping in the training dataset. Right? If so, I do not understand the reason for error difference.

The answer is that 25 patients have dependent measurements. But I do not get why it affected the test dataset and not out-of-bag error.

• Please add the [self-study] tag & read its wiki. Jul 21, 2015 at 16:36

## 1 Answer

This is how the OOB error estimate is computed in RF: at any given step in the forest building process, any observation in the original data set can be fed to all the trees that were trained on bootsrap samples devoid of this observation. Approximately one third (~37%) of the total number of trees will meet this condition. Further, by letting these tree vote and taking the most popular class, a prediction can be obtained for the observation. The number of times the prediction differs from the true label of the observation averaged over all classes, gives the out-of-bag error estimate.

Breiman (2001) showed that this estimate was unbiased, and was very similar to Cross-Validation (CV), however, like CV, the way it estimates error is inherently limited by the training data. If specific scenarios or concepts are in an external testing set but absent from the training set (that is used for CV, or to compute OOB error estimate), this new signal won't be captured by the RF model. This will decrease its testing set performance, even though performance on the training set may seem very good as measured by OOB or CV.

• so, it has nothing to do with the dependent measurements, right? Jul 22, 2015 at 18:01
• your not worried that the measurements are not independent? (and that the OOB estimate assumes independent observations) Jul 22, 2015 at 23:01
• @Charles I don't think that the OOB estimate assumes anything. According to this paper by Breiman, algorithmic modeling (unlike parametric modeling) does not make any assumption about the underlying process from which the observations originate, nor about the true relationships between input and output variables. So there is no such thing as IID Jul 23, 2015 at 11:07
• now, if some time pattern has to be captured about the signal, you need to state the problem more precisely: how was the training test constituted with respect to the time series? The testing set? Jul 23, 2015 at 11:10