File: ChainModel.R

package info (click to toggle)
r-cran-mlr 2.13-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,760 kB
  • sloc: ansic: 65; sh: 13; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#' Only exported for internal use.
#' @param next.model ([WrappedModel])\cr
#'   The next model.
#' @param cl ([character])\cr
#'   Subclass to assign to the resulting model.
#'
#' @keywords internal
#' @export
makeChainModel = function(next.model, cl) {
  setClasses(list(next.model = next.model), c(cl, "ChainModel", "WrappedModel"))
}


#'@export
getLearnerModel.BaseWrapperModel = function(model, more.unwrap = FALSE) {
  # FIXME: this structure and special-cases really suck. FailureModel and NoFeaturesModel
  # should probably be redesigned at some point
  if (inherits(model$learner.model, "NoFeaturesModel"))
    return(model$learner.model)
  if (more.unwrap)
    getLearnerModel(model$learner.model$next.model, more.unwrap = TRUE)
  else
    model$learner.model$next.model
}

#' @export
print.ChainModel = function(x, ...) {
  print(x$next.model)
}