-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
#support for SuperLearner wrappers, obviously not the most efficient approach, we should reimplement as many as possible | ||
#' Methods for SuperLearner Objects | ||
#' | ||
#' Support for \code{SuperLearner} wrappers, obviously not the most efficient | ||
#' approach, we should reimplement as many as possible. | ||
#' | ||
#' @importFrom assertthat assert_that is.count is.flag | ||
#' | ||
#' @export | ||
#' @rdname undocumented_learner | ||
# | ||
Lrnr_pkg_SuperLearner_method <- R6Class(classname = "Lrnr_pkg_SuperLearner_method", | ||
inherit= Lrnr_base, | ||
portable = TRUE, | ||
class = TRUE, | ||
public = list( | ||
initialize = function(method, ...) { | ||
params=list(method=method, ...) | ||
super$initialize(params=params, ...) | ||
}), | ||
private = list( | ||
.train = function(task) { | ||
method <- self$params$method | ||
X <- as.matrix(task$X) | ||
Y <- task$Y | ||
|
||
fit_object <- method$computeCoef(X, Y, names(X), verbose=FALSE, obsWeights=task$weights) | ||
return(fit_object) | ||
|
||
}, | ||
.predict = function(task){ | ||
coef <- private$.fit_object$coef | ||
X <- as.matrix(task$X) | ||
|
||
predictions = method$computePred(X, coef) | ||
return(predictions) | ||
}, | ||
.required_packages = c("SuperLearner") | ||
|
||
) | ||
inherit = Lrnr_base, portable = TRUE, | ||
class = TRUE, | ||
public = list( | ||
initialize = function(method, ...) { | ||
params = list(method = method, ...) | ||
super$initialize(params=params, ...) | ||
} | ||
), | ||
private = list( | ||
.train = function(task) { | ||
method <- self$params$method | ||
X <- as.matrix(task$X) | ||
Y <- task$Y | ||
|
||
fit_object <- method$computeCoef(X, Y, names(X), verbose = FALSE, | ||
obsWeights = task$weights) | ||
return(fit_object) | ||
}, | ||
.predict = function(task) { | ||
coef <- private$.fit_object$coef | ||
X <- as.matrix(task$X) | ||
predictions = method$computePred(X, coef) | ||
return(predictions) | ||
}, | ||
.required_packages = c("SuperLearner") | ||
) | ||
) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.