Skip to contents

CRAN Version CRAN Downloads GitHub Version R build status

Reinforcement Learning Trees is an R package for random forest models with regression, classification, and survival analysis support. The package uses a C++/Rcpp backend with OpenMP for parallel computation.

For Python, see the Python version.

Website | GitHub | Issues

Highlights

  • Regression, classification, and survival forests
  • Reinforcement learning splits with embedded model guidance
  • Linear combination splits for multivariate split directions
  • Variable importance and random forest kernel utilities
  • Survival prediction, confidence bands, and tree inspection tools
  • Reproducible parallel fitting through recorded random seeds

The default fit uses ordinary single-variable splits. Set reinforcement = TRUE to guide those splits with embedded models fitted within nodes. Linear combination splits use a combined predictor direction and are selected separately with linear.comb > 1; they do not require reinforcement. The Get Started guide shows an ordinary fit and a reinforced fit using the same data and settings.

Installation

These guides describe RLT source version 6.1.1. The CRAN release is a separate, older version whose interfaces and features may differ. Source installation requires a C++ toolchain compatible with your R installation. Set it up using the platform requirements, then install the latest GitHub source into your normal shared R library:

# install.packages("remotes")
remotes::install_github("teazrq/RLT")
packageVersion("RLT")

GitHub installation uses the repository’s current default branch. packageVersion() checks the version number, which may be shared by different source revisions. See matching the documentation revision when you need the exact source used by these guides.

The separate CRAN release can be installed with:

On Windows, use the matching Rtools. For macOS and Linux requirements, see the installation guide. OpenMP enables parallel computation; builds without it run serially. Windows builds with and without OpenMP have been validated. Source installation on Ubuntu Linux is checked by the documentation workflow. macOS source installation has not been verified.

Quick Example

library(RLT)

set.seed(1)
n <- 200
p <- 6
x <- matrix(rnorm(n * p), n, p)
y <- x[, 1] - x[, 2] + rnorm(n)

fit <- RLT(
  x, y,
  model = "regression",
  ntrees = 100,
  importance = TRUE,
  seed = 1,
  verbose = FALSE
)

pred <- predict(fit, x[1:5, ])
pred$Prediction

importance(fit)

The five training rows illustrate the returned numeric predictions. To evaluate prediction performance, use out-of-bag predictions or held-out observations as in the Get Started analysis. importance(fit) reports how much the fitted forest relies on each predictor.

Documentation

Use the guides to install RLT, fit models, and interpret their predictions:

References

Cite the papers relevant to the methods used: Zhu et al. (2015) for reinforcement learning trees, Xu et al. (2024) for matched-sample variance estimation, and Formentini et al. (2022) for the CHF covariance and Gaussian-simulation framework for survival bands.

  • Zhu, R., Zeng, D., and Kosorok, M. R. (2015). Reinforcement Learning Trees. Journal of the American Statistical Association, 110(512), 1770-1784. https://doi.org/10.1080/01621459.2015.1036994
  • Xu, T., Zhu, R., and Shao, X. (2024). On variance estimation of random forests with Infinite-order U-statistics. Electronic Journal of Statistics, 18(1), 2135-2207. https://doi.org/10.1214/24-EJS2247
  • Formentini, S. E., Liang, W., and Zhu, R. (2022). Confidence Band Estimation for Survival Random Forests. arXiv preprint, arXiv:2204.12038. https://arxiv.org/abs/2204.12038