StatFAS tutorial · Updated
How to Analyse a Random Forest Model Online
This tutorial walks through a complete classification analysis in the StatFAS Random Forest calculator, from loading data to copying APA 7 results. You need no coding. Everything runs in your browser and your data are not uploaded to a server.
New to Random Forests? Start with Random Forests Explained.
1Prepare your data
- One row per case, one header row, and columns separated by commas, tabs or semicolons (copying cells from Excel works).
- Outcome: one column with 2 to 8 categories (for example
Email,SMS,Voice). - Predictors: at least two numeric columns. Code categories as numbers first (for example gender 0/1, tariff 0–3).
- Rows with a missing outcome or predictor value are excluded listwise, and the report tells you how many. You need at least 20 complete cases.
2Load the data
Paste into the text box, or choose a CSV/TSV/TXT file, then click Read data. The tool reports how many rows and columns it found. With the example data, the last column (channel) is selected as the outcome automatically.
3Choose outcome and predictors
Pick the outcome in Outcome (class) column. All numeric columns are ticked as predictors by default; untick identifiers (such as case numbers) or anything that would not be available when predicting. Including irrelevant columns is allowed, since forests are good at ignoring them, but IDs can mislead.
4Set the forest
| Setting | What it does | Suggested start |
|---|---|---|
| Trees | Number of trees voted together. More trees give steadier results. | 100–500 |
| Max depth | Maximum levels per tree. Shallower trees are easier to read; deeper trees fit more detail. | 3–6 for viewing, more for accuracy |
| Min leaf size | Smallest number of cases allowed in a leaf. Larger values smooth the model. | 1–5 |
| mtry | Features tried at each split. 0 means the square root of the number of predictors. | 0 (automatic) |
| Seed | Makes the random draws repeatable, so you and others can reproduce the run. | Any number; keep it and report it |
Click Run Random Forest. The results appear below within seconds for typical data.
5Read the summary
The summary lists the sample size, trees, mtry, depth, out-of-bag (OOB) accuracy and Cohen’s κ. OOB accuracy comes from cases each tree did not see during training, so it is an honest estimate without a separate test set. κ corrects accuracy for agreement expected by chance; values nearer 1 mean stronger agreement.
Example result (example data, default settings, seed 42): N = 300, 100 trees, mtry = 3, depth ≤ 5, OOB accuracy = .92, κ = .88.
6Interpret the five figures
Figure 1: Feature importance. Bars show Gini importance (larger means the feature cut impurity more across the forest); black markers show each feature’s share of all splits. In the example, avg_kb_week (.43), avg_sms_week (.22) and tariff (.21) dominate, while gender, client_app and standing_order are about .01. That is the pattern of a sparse problem: a few strong features and several noise features (Biau, 2012).
Figure 2: Tree scatterplot. Each dot is a tree: impurity on the x-axis, its highest feature importance on the y-axis, colour by that feature. Click any dot to load it into Figure 5. Look for clusters and outlying trees.
Figure 3: Classification grid. Rows are features, columns are tree depths, and each stacked bar shows which class the splits on that feature favour at that depth. Features whose bars are dominated by one colour are linked to that class.
Figure 4: Pyramid matrix. Each pie summarises leaves whose rule path uses both features (the diagonal shows single features). A near-single-colour pie means that pair points strongly to one class; evenly mixed pies indicate weaker influence. Hover to read percentages.
Figure 5: Single tree. Bars at each node show class counts, the label gives the split rule (feature ≤ threshold), link thickness shows how many cases flowed through, and circles at the leaves are coloured by majority class. Follow a path from the root to see a classification rule.
7Copy your APA 7 results
Scroll to APA 7 report. It contains Method and Results paragraphs, tables of importance, per-class precision, recall and F1, and the OOB confusion matrix, figure captions, a short sparsity note, limitations, and the reference list. Click Copy report to paste into Word with formatting, or Download report (.html). Then replace generic wording with your own research question and variable names.
8Customise the figures
- Appearance card (global): class colour palette (including a colour-blind-safe one), font type, font size, line width, bar width, light/dark page.
- Left panel beside each figure: text and line colour, font size, font type, B bold and I italic (Figure 1 also has a bar colour). Changing the global font settings resets each figure’s font.
- Download SVG under each figure gives a vector file for papers and slides.
9Troubleshooting
| Message | Fix |
|---|---|
| Select at least two numeric predictors | Tick more columns, or convert text predictors to numbers. |
| The outcome must have 2 to 8 categories | Choose a categorical column or merge rare categories. A continuous outcome is not supported. |
| At least 20 complete cases are needed | Check missing values or the delimiter in your pasted data. |
Reporting checklist
- Sample size and how missing data were handled.
- Trees, mtry, depth, minimum leaf size and seed.
- OOB accuracy, κ and per-class metrics.
- Importance table and the figure(s) you discuss.
- Software citation and key references below.
How to cite
Biau, G. (2012). Analysis of a random forests model. Journal of Machine Learning Research, 13(38), 1063–1095. https://jmlr.org/papers/v13/biau12a.html
Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5–32. https://doi.org/10.1023/A:1010933404324
Maçãs, C., Campos, J. R., Lourenço, N., & Machado, P. (2024). Visualisation of random forest classification. Information Visualization, 23(4), 312–327. https://doi.org/10.1177/14738716241260745
StatFAS. (). Random forest calculator and visualiser [Online tool]. https://statfas.com/random-forest-calculator
In text: (StatFAS, ). The date updates automatically each day.