R/getTaskConstructorForLearner.R

Defines functions getTaskConstructorForLearner

getTaskConstructorForLearner = function(learner) {
  while (inherits(learner, "BaseWrapper")) {
    learner = learner$next.learner
  }
  cl = class(learner)

  if ("RLearnerRegr" %in% cl) {
    constructor = makeRegrTask
  } else if ("RLearnerClassif" %in% cl) {
    constructor = makeClassifTask
  } else if ("RLearnerSurv" %in% cl) {
    constructor = makeSurvTask
  } else if ("RLearnerCluster" %in% cl) {
    constructor = makeClusterTask
  } else {
    stop("Unknown learner class for impute")
  }
  constructor
}
berndbischl/mlr documentation built on Aug. 15, 2024, 4:20 p.m.