mlr Tutorial

This web page provides an in-depth introduction on how to use the mlr framework for machine learning experiments in R.

We focus on the comprehension of the basic functions and applications. More detailed technical information can be found in the manual pages which are regularly updated and reflect the documentation of the current package version on CRAN.

An offline version of this tutorial is available for download

The tutorial explains the basic analysis of a data set step by step. Please refer to sections of the menu above: Basics, Advanced, Extend and Appendix.

During the tutorial we present various simple examples from classification, regression, cluster and survival analysis to illustrate the main features of the package.

Enjoy reading!

Quick start

A simple stratified cross-validation of linear discriminant analysis with mlr.

library(mlr)
data(iris)

## Define the task
task = makeClassifTask(id = "tutorial", data = iris, target = "Species")

## Define the learner
lrn = makeLearner("classif.lda")

## Define the resampling strategy
rdesc = makeResampleDesc(method = "CV", stratify = TRUE)

## Do the resampling
r = resample(learner = lrn, task = task, resampling = rdesc, show.info = FALSE)

## Get the mean misclassification error
r$aggr
#> mmce.test.mean 
#>           0.02