How imbs-hl/ranger works
Main Components to Feature
a. R Package Interface:
• R layer (files in the “R” directory and package metadata files such as DESCRIPTION, NAMESPACE, NEWS) that wraps the core functionality.
• That this layer uses Rcpp to bridge to the core C++ functionality.
b. Core C++ Library:
• Central C++ code found in the “src” directory (e.g., Forest.cpp, Tree.cpp, and their variants for different forest types) along with common utilities.
• That this layer implements the essential tree building, splitting, prediction, and utility algorithms.
c. Standalone C++ Version:
• A separate yet related module under “cpp_version” which contains its own CMake configuration files, a slightly different directory structure (including an independent main.cpp) and tests.
• This version can be seen as a demonstration or a production-ready command-line tool for executing random forests on a dataset with specific options (e.g., number of trees, threads).
d. Testing and Continuous Integration:
• Testing component, visible in both the “tests” directory (with testthat tests for the R version and C++ tests in cpp_version/test) and the GitHub workflow configuration under “.github/workflows”.
• CI/CD pipeline that automatically runs builds and tests (e.g., using R-CMD-check, cpp-build, pkgdown workflows) on commits.
e. Documentation and Build Infrastructure:
• Incorporate the documentation pieces (the README, manual pages in “man”, and pkgdown configuration) that guide both usage and contribution.
• Build configuration components like CMakeLists.txt (in cpp_version) and Makevars (in “src”) that are essential for compiling the C++ code.
Relationships and Interactions
• That the standalone C++ executable (from the cpp_version folder) also uses the core modules but is compiled separately (different build instructions using CMake).
• Testing components with both the R and C++ modules to reflect that functionality is continuously verified.
Architectural Patterns and Technologies
• Separation of concerns between the modeling algorithms (implemented in C++), the front-end interface (R wrappers), and the integration layers (standalone executable and tests).
• Use of C++14 and CMake for building the C++ side and R's native package infrastructure (plus Rcpp) to integrate the performance-critical components.
• Mention that the project structure supports modularity by separating tree functionalities (classification, regression, probability, survival) into distinct source files and directories.