Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2024/iii/paper-218/3/d/solution

The loop performs Leave-one-out cross-validation: for each it fits a forest to the other eight observations, tests it on observation , and averages the nine zero-one losses. A random forest's out-of-bag error estimate approximates the same held-out prediction error from one fit, because each tree automatically omits roughly a proportion of the observations in its bootstrap sample.

New to topics? Read the docs here!