Random Forest Explained in Code: Bagging by Hand
One deep tree scored 0.728 on test; a hundred random trees together scored 0.842.
Video #189 ยท Machine learning and data science
Steps in the video
Files
- data.py (11 lines)
- forest.py (19 lines)
- run.py (20 lines)
Tested with
Python 3.12.15 | numpy==2.5.4, scikit-learn==1.9.1, scipy==1.18.1, joblib==1.6.0, narwhals==2.27.1, threadpoolctl==3.7.0, cloudpickle==3.1.2
What this does not show
Made-up data, one train and test split, one seed, and no tuning; the trees themselves come from scikit-learn.
Sources
Learning IT by Example.