← All posts

How Random Forest Hyperparameters Affect Model Performance

Clinical Epidemiology ResearchUniqcret doctor knowledgesMethodology and Research DesignMethodologic [Methodology]
On this page

Random Forest performance is driven by three core mechanisms:

Each parameter influences one or more of these mechanisms.


Category 1: Tree Structure Parameters (Most Important for Performance)

These parameters control how each individual tree grows and directly affect the bias–variance trade-off.

1. Features per split (mtry / maximum features)

Low number of featuresHigh number of features
Few variables considered at each splitMany variables considered
High randomnessLow randomness
Trees very different (low correlation)Trees similar (high correlation)
Higher biasLower bias
Lower variance (better ensemble effect)Higher variance (less benefit from averaging)

Interpretation: This parameter controls how similar the trees are to each other. It is the most important tuning parameter because reducing correlation between trees greatly improves ensemble performance.

2. Minimum node size (min.node.size / minimum samples per leaf)

Small minimum node sizeLarge minimum node size
Very small terminal nodesLarger terminal nodes
Highly complex treesSimpler trees
Captures fine details (including noise)Produces smoother predictions
Lower biasHigher bias
Higher variance (overfitting risk)Lower variance (underfitting risk)

Interpretation: This is the primary parameter that controls overfitting. Smaller values allow the model to memorize data; larger values force it to generalize.

3. Maximum tree depth (maximum depth)

Shallow treesDeep trees
Limited interactions capturedComplex interactions captured
Higher biasLower bias
Lower varianceHigher variance
Risk of underfittingPotential overfitting

Interpretation: In Random Forest, trees are usually allowed to grow fully because bagging already controls overfitting. Limiting depth is rarely necessary.

4. Minimum samples required to split (minimum samples to split)

Small minimum split sizeLarge minimum split size
Splits occur easilySplits occur less often
More complex treesSimpler trees
Lower biasHigher bias
Higher varianceLower variance

Interpretation: This parameter influences when splitting is allowed, but has less impact than minimum node size.

5. Maximum number of leaf nodes (maximum leaf nodes)

Few leaf nodesMany leaf nodes
Strong restriction on tree sizeMinimal restriction
Simpler treesMore complex trees
Higher biasLower bias
Lower varianceHigher variance

Interpretation: Another way to limit tree complexity. Its role overlaps with the minimum node size.


Category 2: Ensemble Parameters

These parameters control how multiple trees are built and combined.

6. Number of trees (number of estimators)

Few treesMany trees
Unstable predictionsStable predictions
Higher varianceLower variance
Sensitive to sampling noiseRobust averaging
Faster computationSlower computation

Interpretation: Increasing the number of trees reduces variance and stabilizes predictions. Performance improves until it plateaus (typically around 300–500 trees).

7. Sample fraction (fraction of data per tree)

Small sample fractionLarge sample fraction
Each tree sees less dataEach tree sees more data
Higher diversity between treesLower diversity
Higher biasLower bias
Lower variance (better ensemble effect)Higher variance (trees are more similar)

Interpretation: Controls how similar trees are. Smaller fractions increase diversity and can reduce overfitting.

8. Bootstrap sampling (sampling with replacement)

Without replacementWith replacement
More unique observations per treeSome observations repeated
Trees more similarTrees more diverse
Slightly higher varianceLower variance

Interpretation: Standard Random Forest uses sampling with replacement to increase variability across trees.

9. Class weighting (class weights)

No class weightingBalanced class weighting
Majority class dominates learningMinority class emphasized
Higher overall accuracyBetter minority detection
Lower sensitivity for rare eventsHigher sensitivity for rare events
Better probability calibrationPossible distortion of predicted probabilities

Interpretation: This parameter changes how the model prioritizes errors. In clinical prediction, recalibration is often preferred over weighting when probability estimates are important.


Category 3: Feature Handling Parameters

These parameters control how features are evaluated during splitting.

10. Split rule (criterion for split quality)

Standard split rule (e.g., Gini)More random split rule (e.g., Extra Trees)
Deterministic optimal splitsRandomized split points
Lower biasSlightly higher bias
Higher varianceLower variance
Stable performanceMore randomness

Interpretation: The choice of the split rule has a relatively small impact. Standard methods such as Gini impurity work well in most situations.

11. Feature importance method

Impurity-based importancePermutation-based importance
Fast to computeSlower to compute
Biased toward variables with many categoriesUnbiased
Less reliable for interpretationMore reliable for interpretation

Interpretation: This does not affect model performance but is critical for interpreting predictors.


Category 4: Computational / Reproducibility Parameters

These parameters do not affect model performance but ensure reproducibility and efficiency.

12. Random seed (random state)

Not fixedFixed
Results vary between runsResults reproducible
Hard to debugConsistent outputs

Interpretation: Always fix a random seed to ensure reproducibility.

13. Number of parallel threads (number of jobs)

Single threadMultiple threads
Slower trainingFaster training
Lower resource useHigher CPU usage

Interpretation: Controls computation speed only.

14. Verbose output (verbosity level)

Low verbosityHigh verbosity
Minimal outputDetailed progress logs
Cleaner consoleMore transparency

Interpretation: Useful for monitoring training progress.

15. Warm start (incremental tree building)

DisabledEnabled
Model trained from scratchTrees added incrementally
Simpler workflowFlexible model expansion

Interpretation: Allows adding more trees without retraining from the beginning.

16. Out-of-bag error estimation (OOB score)

DisabledEnabled
No internal validationBuilt-in validation using unused samples
Requires external validationQuick performance estimate

Interpretation: Provides an internal estimate of model performance without separate validation data.


Final Conceptual Summary

Random Forest performance depends on balancing:

The most influential parameters are:

  1. Features per split (controls correlation between trees)
  2. Minimum node size (controls overfitting)
  3. Sample fraction (secondary diversity control)

Key Takeaways

0
Message for International and Thai ReadersUnderstanding My Medical Context in ThailandRead more →Message for International and Thai ReadersUnderstanding My Broader Content Beyond MedicineRead more →

Comments

No comments yet. Be the first to share your thoughts.

Sign in to comment