Skip to content

Commit

Permalink
fix family/closure error
Browse files Browse the repository at this point in the history
  • Loading branch information
nhejazi committed Oct 9, 2017
1 parent 6c1c378 commit 197ff48
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 72 deletions.
8 changes: 4 additions & 4 deletions R/Lrnr_pkg_SuperLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @field ... Additional arguments. Currently unused.
#'
#' @importFrom R6 R6Class
#' @importFrom stats gaussian
#' @importFrom stats gaussian predict
#'
#' @export
#
Expand Down Expand Up @@ -48,7 +48,7 @@ Lrnr_pkg_SuperLearner <- R6Class(classname = "Lrnr_pkg_SuperLearner",
family <- family()
}
}
fit_object <- wrapper(task$Y, task$X, newX, family = stats::family,
fit_object <- wrapper(task$Y, task$X, newX, family = family,
obsWeights = task$weights, id = task$id)$fit
return(fit_object)
},
Expand All @@ -61,8 +61,8 @@ Lrnr_pkg_SuperLearner <- R6Class(classname = "Lrnr_pkg_SuperLearner",
family <- family()
}
}
predictions = predict(private$.fit_object, newdata = task$X,
family = family)
predictions = stats::predict(private$.fit_object, newdata = task$X,
family = family)
return(predictions)
},
.required_packages = c("SuperLearner")
Expand Down
62 changes: 32 additions & 30 deletions R/Lrnr_pkg_SuperLearner_method.R
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")
)
)

5 changes: 2 additions & 3 deletions man/Lrnr_HarmonicReg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Lrnr_arima.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Lrnr_base.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Lrnr_condensier.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Lrnr_cv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Lrnr_define_interactions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/Lrnr_expSmooth.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions man/Lrnr_pkg_SuperLearner_method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/Lrnr_rugarch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Lrnr_tsDyn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Pipeline.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/Stack.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions man/undocumented_learner.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 197ff48

Please sign in to comment.