Skip to contents

The following learners are available for continuous outcomes:

Value

Every learner function shares the same structure: when called with (data, formula, ...) it fits the underlying model and returns a prediction closure which is a function of newdata returning a numeric vector of predictions (predicted probabilities of the second factor level for binary learners; predicted densities for density learners; a matrix of class probabilities for multiclass learners).

Details

  • lnr_bart

  • lnr_cvglmnet

  • lnr_earth

  • lnr_gam

  • lnr_gausspr

  • lnr_gbm

  • lnr_glm

  • lnr_glmer

  • lnr_glmnet

  • lnr_glmnet_grid

  • lnr_hal

  • lnr_hal_grid

  • lnr_knn

  • lnr_lightgbm

  • lnr_lm

  • lnr_lmer

  • lnr_mean

  • lnr_ppr

  • lnr_ranger

  • lnr_rpart

  • lnr_rf

  • lnr_svm

  • lnr_xgboost

See ?density_learners to learn more about using conditional density estimation in nadir.

lnr_mean is generally provided only for benchmarking purposes to compare other learners against to ensure correct specification of learners, since any prediction algorithm should (in theory) out-perform just using the mean of the outcome for all predictions.

If you'd like to build a new learner, we recommend reading the source code of several of the learners provided with {nadir} to get a sense of how they should be specified.

A learner, as {nadir} understands them, is a function which takes in data, a formula, possibly ..., and returns a function that predicts on its input newdata.

A simple example is reproduced here for ease of reference:

Examples

lnr_glm <- function(data, formula, weights = NULL, ...) {
  model <- stats::glm(formula = formula, data = data, weights = weights, ...)

  return(function(newdata) {
    predict(model, newdata = newdata, type = "response")
  })
}