An open API service indexing awesome lists of open source software.

https://github.com/nt-williams/mlr3superlearner

Super learner fitting and prediction using mlr3
https://github.com/nt-williams/mlr3superlearner

ensemble-learning machine-learning

Last synced: 5 months ago
JSON representation

Super learner fitting and prediction using mlr3

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# mlr3superlearner

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/nt-williams/mlr3superlearner/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nt-williams/mlr3superlearner/actions/workflows/R-CMD-check.yaml)

An modern implementation of the [Super Learner](https://biostats.bepress.com/ucbbiostat/paper266/) prediction algorithm using the [mlr3](https://mlr3.mlr-org.com/) framework, and an adherence to the recommendations of [Phillips, van der Laan, Lee, and Gruber (2023)](https://doi.org/10.1093/ije/dyad023)

## Installation

You can install the development version of mlr3superlearner from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("nt-williams/mlr3superlearner")
```

## Example

```{r example}
library(mlr3superlearner)
library(mlr3extralearners)

# No hyperparameters
mlr3superlearner(mtcars, "mpg", c("mean", "glm", "svm", "ranger"), "continuous")

# With hyperparameters
fit <- mlr3superlearner(mtcars, "mpg",
list("mean", "glm", "xgboost", "svm", "earth",
list("nnet", trace = FALSE),
list("ranger", num.trees = 500, id = "ranger1"),
list("ranger", num.trees = 1000, id = "ranger2")),
"continuous")

fit

head(data.frame(pred = predict(fit, mtcars), truth = mtcars$mpg))
```

## Available learners

```{r}
knitr::kable(available_learners("binomial"))
knitr::kable(available_learners("continuous"))
```