100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Machine Learning with Scikit-learn
30 minintermediate

Random Forest and Feature Importance

Random forests are ensemble classifiers and regressors that build hundreds of decision trees in parallel, each on a random bootstrap sample of the training data and with a random subset of features considered at each split, then average their predictions. This combination of bootstrap sampling (bagging) and random feature selection creates diverse, decorrelated trees whose average has much lower variance than any individual tree while preserving the low bias of deep trees.

Random forests are consistently among the top-performing algorithms for tabular data, requiring minimal feature preprocessing, producing reliable feature importances (with known caveats), and being robust to outliers, irrelevant features, and moderate class imbalance. They are often the first complex algorithm to try after logistic regression as a baseline, and their performance frequently sets the benchmark that gradient boosting must beat. Understanding why random forests work — the mechanics of bagging and feature randomisation — explains their robustness and guides effective tuning.

Analogy🏏Cricket
🏏 Think of it like cricket: A batting coach who teaches only one shot — the forward defensive — gives advice with high bias: it is consistently wrong for deliveries that demand a drive or a pull, regardless of how much practice the batsman does. A coach who memorises every ball of the batsman's training career gives advice with high variance: he predicts each training ball perfectly but fails completely on new balls from a different bowler, because he learned the noise of that specific bowler rather than the underlying principles. The great coach finds the balance — teaching the core principles that generalise, without over-specifying for the particular training environment. Just as great coaching lies between the extremes, great ML models balance bias and variance.
Lesson 15 of 35
0% complete