Efficient Machine Learning with R

Low-Compute Predictive Modeling with tidymodels

Author

Simon P. Couch

Welcome🐛

Welcome to Efficient Machine Learning with R! This is a book about predictive modeling with tidymodels, focused on reducing the time and memory required to train machine learning models without sacrificing predictive performance.

This book assumes familiarity with data analysis with the tidyverse as well as the basics of machine learning with tidymodels: fitting models with parsnip, resampling data with rsample, and tuning model parameters with tune. For more on tidy data analysis, see Wickham, Çetinkaya-Rundel, and Grolemund (2023). For the basics of predictive modeling with tidymodels, see Kuhn and Silge (2022).

Caution

This book is in its early drafting stages; many portions of the book are unfinished and all of it will go through significant revision and refinement. Keep an eye out for callout notes like this one to better understand the state of content you find throughout the site.

Outline

  • 1  Introduction demonstrates a 145-fold speedup with an applied example. By adapting a grid search on a canonical model to use a more performant modeling engine, hooking into a parallel computing framework, transitioning to an optimized search strategy, and defining the grid to search over carefully, the section shows that users can drastically cut down on tuning times without sacrificing predictive performance. The following chapters then explore those optimizations in further details.

  • 2  Models explores timings to resample various different modeling engines. The chapter compares implementations both within and across model types.

  • 3  Parallel computing compares various approaches to distributing model computations across CPU cores. We’ll explore two different across-model parallel computing frameworks supported by tidymodels—process forking and socket clusters—and explore their relationship to within-model parallelization.

  • Then, 4  Search explores various alternatives to grid search that can reduce the total number of model fits required to search a given grid space by only resampling models that seem to have a chance at being the “best.”

  • Finally, 5  The submodel trick investigates approaches to designing grids that can further reduce the total number of model fits required to search a given grid space by generating predictions from one model that can be used to evaluate several.

The optimizations discussed in those aforementioned chapters can, on their own, substantially reduce the time to evaluate machine learning models with tidymodels. Depending on the problem context, some modeling workflows may benefit from more specialized optimizations. The following chapters discuss some of those use cases: