Random Forest › Visualizing Random Forest
Machine Learning from ScratchAll chapters Random Forest › Visualizing Random ForestOne section · Sections in this chapter3 / 9 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Let's create visualizations that demonstrate how Random Forest works and how it differs from individual decision trees.


Now let's visualize how the number of trees affects the Random Forest performance:

Note on Out-of-Bag (OOB) Error: The OOB error calculation requires a sufficient number of trees to provide reliable estimates. With very few trees, some observations may not be "out-of-bag" for any tree, making OOB scores unavailable. This is why we start the visualization from 10 trees rather than 1, and why scikit-learn may issue warnings about insufficient OOB samples when using very small numbers of trees. The OOB error provides a useful estimate of generalization performance without needing a separate validation set, but it becomes more reliable as the number of trees increases.