@@ -221,6 +221,37 @@ PipeOpTargetTrafo = R6Class("PipeOpTargetTrafo",
221221# ' @section Methods:
222222# ' Only methods inherited from [`PipeOp`].
223223# '
224+ # ' @examplesIf requireNamespace("rpart")
225+ # ' library(mlr3)
226+ # ' task = tsk("boston_housing")
227+ # ' po = PipeOpTargetMutate$new("logtrafo", param_vals = list(
228+ # ' trafo = function(x) log(x, base = 2),
229+ # ' inverter = function(x) list(response = 2 ^ x$response))
230+ # ' )
231+ # ' # Note that this example is ill-equipped to work with
232+ # ' # `predict_type == "se"` predictions.
233+ # '
234+ # ' po$train(list(task))
235+ # ' po$predict(list(task))
236+ # '
237+ # ' g = Graph$new()
238+ # ' g$add_pipeop(po)
239+ # ' g$add_pipeop(LearnerRegrRpart$new())
240+ # ' g$add_pipeop(PipeOpTargetInvert$new())
241+ # ' g$add_edge(src_id = "logtrafo", dst_id = "targetinvert",
242+ # ' src_channel = 1, dst_channel = 1)
243+ # ' g$add_edge(src_id = "logtrafo", dst_id = "regr.rpart",
244+ # ' src_channel = 2, dst_channel = 1)
245+ # ' g$add_edge(src_id = "regr.rpart", dst_id = "targetinvert",
246+ # ' src_channel = 1, dst_channel = 2)
247+ # '
248+ # ' g$train(task)
249+ # ' g$predict(task)
250+ # '
251+ # ' #syntactic sugar using ppl():
252+ # ' tt = ppl("targettrafo", graph = PipeOpLearner$new(LearnerRegrRpart$new()))
253+ # ' tt$param_set$values$targetmutate.trafo = function(x) log(x, base = 2)
254+ # ' tt$param_set$values$targetmutate.inverter = function(x) list(response = 2 ^ x$response)
224255# ' @family PipeOps
225256# ' @template seealso_pipeopslist
226257# ' @include PipeOp.R
0 commit comments