Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 05 / Topic 5 of 7

Random forests

A random forest trains many trees, each on a bootstrap sample of the rows with random subsets of features, and averages their votes. Individually overfitted trees disagree on their mistakes; the average cancels much of the noise. The price: less interpretability and more memory.

RandomForestClassifier(n_estimators=200, random_state=42)

Two knobs matter most: n_estimators (more trees = more stable, slower) and max_depth (controls each tree's complexity). Part 8 tunes them properly.

Done here? The practice set for Part 5 — 4 exercises with solutions — is on the part page.

Search the guide