Your deployed Random Forest is too large in memory to serve. How would you shrink it while preserving accuracy?

Last updated 5 November 2026

  • Cut tree count at the elbow of OOB score vs. n_estimators (often 100–300). Shrink trees by raising min_samples_leaf or capping max_depth, which is usually the biggest win with negligible accuracy loss.

  • Compact the representation: float32 thresholds, small feature indices, no per-node class counts, or compile with treelite/ONNX.

  • Validate each step on OOB or held-out accuracy. Distill into a compact boosted model or shallow forest if more reduction is needed.

  • https://www.dailydoseofds.com/formulating-and-implementing-xgboost-from-scratch/
  • https://mcpanalytics.ai/articles/random-forest-practical-guide-for-data-driven-decisions
  • https://blog.dailydoseofds.com/p/reduce-trees-in-random-forest-model
All Random Forests interview questions