Model-based boosting, using mboost

if (rlang::is_installed("mboost")) {
  library(tidypredict)
  library(mboost)
  library(dplyr)
  eval_code <- TRUE
} else {
  eval_code <- FALSE
}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = eval_code
)
set.seed(1)

| Function |Works| |---------------------------------------------------------------|-----| |tidypredict_fit(), tidypredict_sql(), parse_model() | ✔ | |tidypredict_to_column() | ✔ | |tidypredict_test() | ✔ | |tidypredict_interval(), tidypredict_sql_interval() | ✗ | |parsnip | ✗ |

How it works

mboost::blackboost() boosts regression trees. Each boosting iteration contributes one tree, shrunk by the learning rate nu, and the contributions are added to the model's offset.

library(mboost)
library(dplyr)
library(tidypredict)

model <- blackboost(
  mpg ~ wt + cyl,
  data = mtcars,
  control = boost_control(mstop = 10)
)

Under the hood

The parser walks the partykit tree behind every boosting iteration and turns it into one nested dplyr::case_when() statement. The learning rate and the offset are folded into the result.

pm <- parse_model(model)
str(pm, 2)

The parsed model is transformed into a dplyr, a.k.a. Tidy Eval, formula.

tidypredict_fit(model)

From there, the Tidy Eval formula can be used anywhere it can be evaluated. tidypredict provides three paths:

mtcars %>%
  tidypredict_to_column(model) %>%
  glimpse()

How it performs

tidypredict_test(model, df = mtcars)

Categorical predictors

blackboost() handles factors natively, and the generated formula uses %in% for the resulting splits.

df <- transform(mtcars, cyl = factor(cyl))

model_cat <- blackboost(
  mpg ~ wt + cyl,
  data = df,
  control = boost_control(mstop = 10)
)

tidypredict_test(model_cat, df = df)

Limitations



Try the tidypredict package in your browser

Any scripts or data that you put into this service are public.

tidypredict documentation built on Oct. 18, 2026, 5:06 p.m.