Hyperparameters

ParameterDescriptionTypical ValuesEffect
n_estimatorsNumber of trees100-500More trees → better performance, slower
max_depthMaximum tree depthNone or 10-30Lower → less overfitting
min_samples_splitMin samples to split2-10Higher → simpler trees
min_samples_leafMin samples per leaf1-5Higher → smoother boundaries
max_featuresFeatures per split’sqrt’, ‘log2’, or numberLower → more diversity
bootstrapUse bootstrap samplesTrueFalse uses all data
oob_scoreUse OOB for validationFalseTrue calculates OOB error

Tuning Strategy

  1. Start with defaults:

    • n_estimators=100
    • max_features=‘sqrt’ (classification) or ‘auto’ (regression)
  2. Increase n_estimators:

    • More trees almost always helps
    • Stop when performance plateaus
  3. Tune max_features:

    • Lower values increase diversity
    • Try sqrt(n), log2(n), n/3
  4. Adjust tree complexity:

    • max_depth, min_samples_split, min_samples_leaf
    • Use to prevent overfitting if needed