What is the training time complexity of building a Random Forest with B trees, N samples and M features?
Last updated
For balanced trees, training costs about O(B · m · N log² N), where m (
mtry) is the features tried per split. Presorting or histograms reduce this to about O(B · m · N log N).Each level costs O(m · N log N) (sorting plus scanning per feature), and a balanced tree has about log N levels. A degenerate chain-like tree worsens to O(m · N² log N).
Cost is linear in B, and using m ≪ M makes RF trees cheaper than full CART trees (O(M · N log² N)).