Multivariate & ML · Machine Learning

Random Forest

Classify or predict with a random forest: hundreds of decorrelated decision trees vote (or average), with honest cross-validated metrics, the out-of-bag score, and seeded permutation importance.

In the menus Multivariate & ML › Machine Learning › Random Forest

Also searched as random forest random forests bagging bootstrap forest

When to use it

Predict a category or a number from a mix of numeric and categorical predictors when the relationship may be non-linear or involve interactions, and you want strong out-of-the-box accuracy with a built-in honesty check (the out-of-bag score). Use it when prediction matters more than an interpretable equation: for interpretable effects, fit a regression on the same columns.

When not to: Interpretability of individual effects is required for stakeholders or regulators (a regression or a single tree is more appropriate), predictions are needed outside the range of the training data for a regression outcome (forests cannot extrapolate; predictions flatten at the edges), or a genuinely numeric column has been mistyped as text, which silently degrades the model unless the card's specific flag for this is checked.

Step by step

  1. Open it from the menu

    Click Multivariate & ML in the menu bar; under Machine Learning choose Random Forest.

  2. Fill in the form

    Choose the columns: What you want to predict, Columns that may explain it. The form lists only columns whose type fits each field.

  3. Check the options

    The options start at their defaults: Trees (n_estimators), Max tree depth, Features per split, Min samples per leaf, CV folds, Random seed. Change one only when your question needs it.

  4. Run the analysis

    Press Run analysis. The Result Card opens on its Results tab.

What to choose in the form

Fields of the Random Forest form
What you want to predict Outcome requiredOne categorical or binary or numeric column. Outcome to predict. Categorical or two-level → classification; continuous numeric → regression.
Columns that may explain it Predictors requiredOne numeric or categorical or binary column. One or more predictors. Numeric columns are used as-is; categorical columns are dummy-encoded (col=level).
Trees (n_estimators)Number of trees in the forest. More trees never overfit: they stabilize the estimate at the cost of compute. Default: 200.
Max tree depthMaximum depth of each tree; 0 = grow fully (the standard forest default). Default: 0.
Features per splitPredictors considered at each split. auto = sqrt(p) for classification, all features for regression (the usual defaults). Default: auto.
Min samples per leafMinimum rows in a leaf. Raising it smooths each tree (less variance, more bias). Default: 1.
CV foldsCross-validation folds (stratified for classification), seeded for reproducibility. Default: 5.
Random seedSeeds the bootstrap draws, the CV shuffle, and permutation importance so results are reproducible. Default: 42.

How to read the card

The Results tab starts with what to know first (rows left out, checks that did not pass), then the interpretation in words and the Key Results; charts and assumption checks follow further down. Learn More explains the method in plain words. Read a Result Card covers all four tabs.

A worked example

Classifying penguin species from four body measurements with 500 trees, comparing OOB score against 5-fold cross-validated accuracy.

Result: OOB score = 97.7%, 5-fold cross-validated accuracy = 97.7% (in-sample 100%); out-of-sample permutation importance ranks bill length highest (0.33) with flipper length second, and the impurity-based ranking also puts bill length first and flipper length second.

The close agreement between OOB and cross-validated accuracy supports trusting both as honest estimates of real-world performance, and the agreement between the two importance measures here (rather than a disagreement) suggests bill length's leading role is a genuine signal rather than an artifact of high cardinality: bill length is what separates Chinstrap from Adelie, which body-size measures cannot.

From the Statistics Library.

The code tabs

Code gives this analysis as Python, R and MATLAB code (and SAS where the tab offers it), reading the data the way KernelStats did. Export sends the card to a report or to slides. See The Code tab.

Understand the statistics

Ask Oobi

Type one of these into Ask Oobi beside your data:

  • Which measurements best identify a penguin's species, and how accurate is the prediction on penguins the model never saw?
  • Explain the random forest in plain words.
  • What does overfitting mean?

Last reviewed November 16, 2026.

Report an unclear step