R-CMD-check test-coverage codecov pkgdown Netlify Status

This R package provides an interface to the spatialML package for the mlr3 ecosystem.

It implements the Geographically Weighted Random Forest (GRF) algorithm for regression tasks.

Documentation

The site can be found at : https://mlr3learners-spatialml-grf.netlify.app/

This site includes API references, usage guides and a detailed performance benchmark (vignettes).

Installation

To install it, you can use this command :

# install.packages("remotes")

# Installing SpatialML
remotes::install_version("SpatialML", version = "0.1.6")

remotes::install_github("MomoNagi/mlr3learners.spatialML")

Usage

This package provides the regr.grf learner for mlr3. It requires a TaskRegrST (Spatio-Temporal Task) from the mlr3spatiotempcv package to correctly handle spatial coordinates.

library(mlr3)
library(mlr3spatiotempcv)
library(mlr3learners.spatialML)

task <- tsk("california_housing")
learner <- lrn("regr.grf", bw = 20, ntree = 50)
learner$train(task)
pred <- learner$predict(task)

Benchmark results

Performance was evaluated using the Root Mean Squared Error (RMSE). Results are based on a 5-fold cross-validation. Values represent the Mean RMSE (± Standard Deviation).

Dataset GRF KNN (Tuned) CV-Glmnet Featureless
California Housing 91,628 (±8,849) 88,497 (±9,489) 81,158 (±10,974) 123,044 (±8,091)
Income 1,776 (±146) 1,630 (±290) 1,921 (±469) 2,929 (±447)

Note : Lower values indicate better performance. Bold values represent the best learner for each task.

We can see that GRF remains competitive with KNN and CVGlmnet. It also stands out as the most stable learner on the Income dataset with the lowest standard deviation. Furthermore, its significant outperformance of the Featureless baseline confirms its effectiveness.

Development

This package includes :

  • End-to-End Testing: Automated test suite ensuring seamless integration between mlr3 and SpatialML
  • Continuous Integration: Validation via GitHub Actions on every push.
  • Documentation: Complete API reference and performance vignettes deployed on Netlify.
  • Vignette: Complete demonstration of the benchmark

Author

Manh Hung LE - GitHub

Licence

MIT License