Skip to contents

Every learner which is implemented in mlr and which supports binary classification can be converted to a wrapped binary relevance multilabel learner. The multilabel classification problem is converted into simple binary classifications for each label/target on which the binary learner is applied.

Models can easily be accessed via getLearnerModel.

Note that it does not make sense to set a threshold in the used base learner when you predict probabilities. On the other hand, it can make a lot of sense, to call setThreshold on the MultilabelBinaryRelevanceWrapper for each label indvidually; Or to tune these thresholds with tuneThreshold; especially when you face very unabalanced class distributions for each binary label.

Usage

makeMultilabelBinaryRelevanceWrapper(learner)

Arguments

learner

(Learner | character(1))
The learner. If you pass a string the learner will be created via makeLearner.

Value

Learner.

References

Tsoumakas, G., & Katakis, I. (2006) Multi-label classification: An overview. Dept. of Informatics, Aristotle University of Thessaloniki, Greece.

Examples

d = getTaskData(yeast.task)
# drop some labels so example runs faster
d = d[seq(1, nrow(d), by = 20), c(1:2, 15:17)]
task = makeMultilabelTask(data = d, target = c("label1", "label2"))
lrn = makeLearner("classif.rpart")
lrn = makeMultilabelBinaryRelevanceWrapper(lrn)
lrn = setPredictType(lrn, "prob")
# train, predict and evaluate
mod = train(lrn, task)
#> Error in x[0, , drop = FALSE]: incorrect number of dimensions
pred = predict(mod, task)
#> Error in predict(mod, task): object 'mod' not found
performance(pred, measure = list(multilabel.hamloss, multilabel.subset01, multilabel.f1))
#> Error in performance(pred, measure = list(multilabel.hamloss, multilabel.subset01,     multilabel.f1)): object 'pred' not found
# the next call basically has the same structure for any multilabel meta wrapper
getMultilabelBinaryPerformances(pred, measures = list(mmce, auc))
#> Error in checkClass(x, classes, ordered, null.ok): object 'pred' not found
# above works also with predictions from resample!