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

baguette

R-CMD-check Lifecycle: stable CRAN status Codecov test coverage

Introduction

The goal of baguette is to provide efficient functions for bagging (aka bootstrap aggregating) ensemble models.

The model objects produced by baguette are kept smaller than they would otherwise be through two operations:

Installation

You can install the released version of baguette from CRAN with:

install.packages("baguette")

Install the development version from GitHub with:

# install.packages("pak")
pak::pak("tidymodels/baguette")

Available Engines

The baguette package provides engines for the models in the following table.

library(parsnip)

parsnip_models <- get_from_env("models") |>
  setNames(., .) |>
  purrr::map_dfr(get_from_env, .id = "model")

library(baguette)

baguette_models <- get_from_env("models") |>
  setNames(., .) |>
  purrr::map_dfr(get_from_env, .id = "model")

dplyr::anti_join(
  baguette_models, parsnip_models, 
  by = c("model", "engine", "mode")
) |>
  knitr::kable()

Example

Let's build a bagged decision tree model to predict a continuous outcome.

library(baguette)

bag_tree() |> 
  set_engine("rpart") # C5.0 is also available here

set.seed(123)
bag_cars <- 
  bag_tree() |> 
  set_engine("rpart", times = 25) |> # 25 ensemble members 
  set_mode("regression") |> 
  fit(mpg ~ ., data = mtcars)

bag_cars

The models also return aggregated variable importance scores.

Contributing

This project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



tidymodels/baguette documentation built on June 11, 2025, 6:44 a.m.