Paper commentary
ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R
ranger implements random forests in C++ and R that scale to genome-wide data
- Problem Common R random forest packages were not built for high dimensional data, and some ran out of memory on genome-wide data.
- Method ranger writes the forest code once in C++ with only standard libraries and exposes it to R through a wrapper.
- Results ranger's GWAS mode took 0.23 hours at mtry 5000, versus 101.24 hours for randomForest.
Why older forest packages stall on wide data
Random forests are used for gene expression, credit scoring and genome-wide association studies, so their software speed matters in practice. The original Fortran implementation had to be recompiled whenever the data or a parameter changed. The randomForest package is feature-rich and widely used, but it was not built for large numbers of features.
The party package and Willows share that weakness, and bigrf handles large data only for classification forests. Random Jungle was built for high dimensional data, but it runs only as a C++ application and can't be called from R. The authors therefore wanted a platform independent package that is simple to use from R and not slower than Random Jungle 2.1.
On GWAS-scale data the problem became concrete, because Rborist and bigrf without disk caching ran out of memory. A package that handles this scale has to keep memory use in check as well as runtime.
A C++ core behind an R wrapper
The key idea is to write the forest code once in C++ with only standard libraries, and to expose it to R through a wrapper. Because the core depends on nothing beyond the standard libraries, a standalone C++ build can be installed on up-to-date platforms. Rcpp turns the R package into a single install command, and the data stay inside R, so no external files are needed.
Parallel processing uses the C++11 thread library, and random numbers come from the random library.
Node splitting is the costliest step, because every one of the mtry candidate features must be scored as a split at each node. The runtime mode uses the first algorithm in large nodes and the second in small nodes, while the memory mode uses only the second. For GWAS data the features are minor allele counts of 0, 1 or 2, so the index already is the value and the sort can be skipped.
Drawing the mtry candidate features in each node was another bottleneck, and Knuth's sampling without replacement gave the major gain. Memory is saved by avoiding copies of the original data, using simple node structures and freeing memory early. Genotypes can be loaded from GenABEL objects into a compact binary format, but this path exists only in the R version.
The split criterion follows the task: the Gini index for classification, the estimated response variance for regression, and the log-rank test for survival.
Matching randomForest on error and importance
To test agreement, the authors compared out-of-bag errors and variable importance with randomForest under identical settings. They simulated a dichotomous endpoint with 2000 samples and 50 features, where a logit model gives an effect to 5 features and none to the other 45. They generated 200 such datasets and grew 5000 trees per forest with both packages on each dataset.
The out-of-bag errors showed no systematic difference between the packages, and the regression check gave similar results.
The importance check used 10,000 forests of 500 trees each, with node impurity as the split criterion. Gini importance and permutation importance were both computed, and the values for the five effect variables came out very similar for the two packages. So on these simulated designs ranger agrees with the reference package.
Runtime on small simulated classification data
The small benchmark varied the number of trees, features, samples and mtry, one at a time, with the other three held fixed. The fixed values were 500 trees, 1000 samples and 1000 features, and each run used a single core. Trees were grown until purity, and the results averaged 20 simulation repeats.
In every simulated scenario ranger outperformed the other four packages. For sample size all packages scaled superlinearly, but only ranger scaled almost linearly. ranger stayed the fastest at every mtry value tested.
The authors note that the gaps add up when several parameters grow together. They did not show those combined runs, so this combined effect is their observation only.
Runtime and memory at GWAS scale
The second benchmark simulated 10,000 subjects and 150,000 features, which the authors call a realistic GWAS scenario. Each forest had 1000 trees, and mtry was 5000, 15,000 or 135,000 features. randomForestSRC, Random Jungle and ranger ran on 12 cores, while the randomForest package can't multithread by itself.
At mtry of 5000, randomForest took 101.24 hours and used 39.05 GB. ranger in GWAS mode finished in 0.23 hours with a peak memory of 0.23 GB. The standard ranger mode took 0.56 hours and 11.26 GB, so the GWAS mode adds a further gain on top of the standard mode.
The save.memory option cut ranger's memory to 0.24 GB but raised its runtime to 0.93 hours. Random Jungle used very little memory, 0.40 GB, but took 1.51 hours at this mtry. The authors conclude that the GWAS mode had both the lowest runtime and the lowest memory of the compared packages.
Where Rborist beats ranger
With 100,000 samples and 100 features, ranger was fastest for dichotomous features, at 0.69 minutes. For continuous features ranger took 5.49 minutes, while Rborist took 2.13 minutes. So the ranking depends on the feature type, and Rborist is the faster choice for continuous features at this size.
To find the boundary, the authors ran 441 combinations of sample sizes from 10 to 100,000 and feature counts from 10 to 1000, using continuous features and 12 cores. ranger was faster at every feature count below 25,000 samples. Above that, Rborist won when features were few, and the threshold rose roughly linearly with sample size. ranger scaled slightly better with cores, so the exact threshold may shift on other hardware.
The authors turn this into a rule: Rborist for low dimensional data with n above 25,000, and ranger otherwise. That rule concerns runtime only, and memory-sparse settings call for save.memory while GWAS data call for the GWAS mode.
Limits of the evidence
Every benchmark uses simulated data, so the validation and runtime results don't show performance on real genotype or clinical data. The GWAS-scale study ran one simulated design, and randomForest (MC) could use only 3 cores at mtry 5000 and 2 cores at the other values because of memory. bigrf without disk caching ran out of memory, and with disk caching the authors stopped it after 16 days.
Rborist grows smaller classification trees than randomForest with default settings, so the packages don't always give the same trees. The GWAS format and mode exist only in the R version, which the authors advise for general use. The authors state they know of no faster random forest implementation for high dimensional data with many features.
Party and Willows were not included in the runtime comparison, so that claim was not tested against them.
Paper info
- Authors
- Marvin N. Wright, Andreas Ziegler
- Venue
- arXiv · Preprint
- First published
- 2015-8-18
- Added
- 2026-11-12
- Updated
- 2018-5-17
- Version
- v2
- arXiv
- 1508.04409
- DOI
- 10.18637/jss.v077.i01
- Category
- stat.ML · stat.CO
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Marvin N. Wright, Andreas Ziegler (2015). ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R. arXiv:1508.04409v2. https://doi.org/10.18637/jss.v077.i01
BibTeX
@article{wright2015ranger,
title = {{ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R}},
author = {Marvin N. Wright and Andreas Ziegler},
year = {2015},
eprint = {1508.04409},
archivePrefix = {arXiv},
doi = {10.18637/jss.v077.i01},
url = {https://arxiv.org/abs/1508.04409v2}
}