Introduction and Overview

The mlr3 (Lang et al. 2019) package and ecosystem provide a generic, object-oriented, and extensible framework for classification, regression, survival analysis, and other machine learning tasks for the R language (R Core Team 2019). This unified interface provides functionality to extend and combine existing learners, intelligently select and tune the most appropriate technique for a task, and perform large-scale comparisons that enable meta-learning. Examples of this advanced functionality include hyperparameter tuning and feature selection. Parallelization of many operations is natively supported.

Note

We do not implement any learners ourselves, but provide a unified interface to many existing learners in R.

Target Audience

We expect that users of mlr3 have at least basic knowledge of machine learning and R. The later chapters of this book describe advanced functionality that requires more advanced knowledge of both. mlr3 is suitable for complex projects that use advanced functionality as well as one-liners to quickly prototype specific tasks.

mlr3 provides a domain-specific language for machine learning in R. We target both practitioners who want to quickly apply machine learning algorithms and researchers who want to implement, benchmark, and compare their new methods in a structured environment.

Note

The package is a rewrite of an earlier version of mlr that leverages many years of experience to provide a state-of-the-art system that is easy to use and extend.

Why a Rewrite?

mlr (Bischl et al. 2016) was first released to CRAN in 2013, with the core design and architecture dating back much further. Over time, the addition of many features has led to a considerably more complex design that made it harder to build, maintain, and extend than we had hoped for. With hindsight, we saw that some design and architecture choices in mlr made it difficult to support new features, in particular with respect to pipelines. Furthermore, the R ecosystem as well as helpful packages such as data.table have undergone major changes in the meantime.

It would have been nearly impossible to integrate all of these changes into the original design of mlr. Instead, we decided to start working on a reimplementation in 2018, which resulted in the first release of mlr3 on CRAN in July 2019. The new design and the integration of further and newly-developed R packages (especially R6, future, and data.table) makes mlr3 much easier to use, maintain, and more efficient compared to its predecessor mlr.

Design Principles

We follow these general design principles in the mlr3 package and ecosystem.

  • Backend over frontend. Most packages of the mlr3 ecosystem focus on processing and transforming data, applying machine learning algorithms, and computing results. We do not provide graphical user interfaces (GUIs); visualizations of data and results are provided in extra packages like mlr3viz.
  • Embrace R6 for a clean, object-oriented design, object state-changes, and reference semantics.
  • Embrace data.table for fast and convenient data frame computations.
  • Unify container and result classes as much as possible and provide result data in data.tables. This considerably simplifies the API and allows easy selection and “split-apply-combine” (aggregation) operations. We combine data.table and R6 to place references to non-atomic and compound objects in tables and make heavy use of list columns.
  • Defensive programming and type safety. All user input is checked with checkmate (Lang 2017). Return types are documented, and mechanisms popular in base R which “simplify” the result unpredictably (e.g., sapply() or the drop argument in [.data.frame) are avoided.
  • Be light on dependencies. One of the main maintenance burdens for mlr was to keep up with changing learner interfaces and behavior of the many packages it depended on. We require far fewer packages in mlr3 to make installation and maintenance easier.

Package Ecosystem

mlr3 builds upon the following packages not developed by core members of the mlr3 team:

  • R6: Reference class objects.
  • data.table: Extension of R’s data.frame.
  • digest: Hash digests.
  • uuid: Unique string identifiers.
  • lgr: Logging facility.
  • mlbench: A collection of machine learning data sets.

All these packages are well curated and mature; we expect no problems with dependencies. Additionally, we suggest the following packages for extra functionality:

The mlr3 package itself provides the base functionality that the rest of ecosystem rely on and some fundamental building blocks for machine learning. The following packages extend mlr3 with capabilities for preprocessing, pipelining, visualizations, additional learners, additional task types, and more:

Tip

A complete list with links to the repositories for the respective packages can be found on our package overview.