Update predict.xgb.Booster.R

add parameter missing
This commit is contained in:
Tong He 2014-11-20 15:19:53 -08:00
parent 98ee7e8057
commit c16e0f6809

View File

@ -25,9 +25,13 @@ setClass("xgb.Booster")
#' @export #' @export
#' #'
setMethod("predict", signature = "xgb.Booster", setMethod("predict", signature = "xgb.Booster",
definition = function(object, newdata, outputmargin = FALSE, ntreelimit = NULL) { definition = function(object, newdata, missing = NULL, outputmargin = FALSE, ntreelimit = NULL) {
if (class(newdata) != "xgb.DMatrix") { if (class(newdata) != "xgb.DMatrix") {
newdata <- xgb.DMatrix(newdata) if (is.null(missing)) {
newdata <- xgb.DMatrix(newdata)
} else {
newdata <- xgb.DMatrix(newdata, missing = missing)
}
} }
if (is.null(ntreelimit)) { if (is.null(ntreelimit)) {
ntreelimit <- 0 ntreelimit <- 0