knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(mlr3) library(mlr3pipelines) library(mlr3multioutput)
Storing and working with multi-output Tasks in mlr3
.
Multi-output Tasks are tasks with multiple targets of possibly different task_types that share the same features (and therefore observations).
The packages scope is currently to ...
t = tsk("linnerud") t
l = lrn("multioutput.featureless") l
l$train(t) p = l$predict(t) p
p$score()
Current limitations:
- One one predict_type: "response"
- One of minimize
, weights etc.
- score() output has to be a scalar.
m1 = msr( "multioutput.custom", measures = list("regr" = msr("regr.mse")), weights = c(Pulls = 1, Squats = 0.3, Jumps = 2) ) m1
p$score(m1)
po("splitmultiout")
: Splits a TaskMultioutput
into one Task
for each target.po("multioutsplit")$train(list(t))
po("multioutunite")
: Unites a Multiplicity
of per-target Predictions
into a PredictionMultioutput
.po("multioutunite") # See example below.
po("multioutlrn")
: Applies one or several Learner
s for each Task in a Multiplicity
.po("multioutlrn", learners = list(lrn("regr.rpart"), lrn("classif.rpart")))
gr = po("multioutsplit") %>>% lrn("regr.rpart") %>>% po("multioutunite") gr = GraphLearner$new(gr) gr$train(t) gr$predict(t)
API:
gr = po("multioutsplit") %>>% po("multioutlrn", learners = list(regr = lrn("regr.rpart"), classif = lrn("classif.rpart"))) gl = GraphLearner$new(gr) gl$train(t) prds = gl$predict(t) prds
Unclear:
- What does the ParamSet
look like? Just unite and prefix with id?
Current problems:
- How to map learners to targets?
- Names are lost through multiplicitlyimply
Internals
gr = po("multioutsplit") %>>% po("multiplicityexply", outnum = 3) %>>% gunion(list( lrn("regr.rpart", id = "rp1"), lrn("regr.rpart", id = "rp2"), lrn("regr.rpart", id = "rp3") )) %>>% po("multiplicityimply", innum = t$target_names) %>>% po("multioutunite") gl = GraphLearner$new(gr) gl$train(t) prds = gl$predict(t) prds
Not implemented
library(mlr3keras) lrn("multioutput.kerasff")
library(mlr3) library(mlr3pipelines) library(mlr3tuning) library(paradox) task = tsk("linnerud") gr = PipeOpSplitMultiout$new() %>>% lrn("regr.rpart") %>>% PipeOpPredictionMultiOutUnite$new() grl = GraphLearner$new(gr) ps = ParamSet$new( list( ParamInt$new("regr.rpart.minsplit", lower = 1, upper = 10), ParamInt$new("regr.rpart.maxdepth", lower = 1, upper = 3) ) ) cv3 = rsmp("cv", folds = 3) ms = MeasureMultioutputWeightedAvg$new(measures = list( "regr" = msr("regr.mse") )) auto = AutoTuner$new( learner = grl, resampling = cv3, measure = ms, search_space = ps, terminator = trm("evals", n_evals = 5), tuner = tnr("random_search") ) auto$train(task)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.