Update utils.R
add parameter missing
This commit is contained in:
parent
ed87eb61bd
commit
bbd7098e51
@ -68,13 +68,17 @@ xgb.Booster <- function(params = list(), cachelist = list(), modelfile = NULL) {
|
|||||||
## ----the following are low level iteratively function, not needed if
|
## ----the following are low level iteratively function, not needed if
|
||||||
## you do not want to use them ---------------------------------------
|
## you do not want to use them ---------------------------------------
|
||||||
# get dmatrix from data, label
|
# get dmatrix from data, label
|
||||||
xgb.get.DMatrix <- function(data, label = NULL) {
|
xgb.get.DMatrix <- function(data, label = NULL, missing = NULL) {
|
||||||
inClass <- class(data)
|
inClass <- class(data)
|
||||||
if (inClass == "dgCMatrix" || inClass == "matrix") {
|
if (inClass == "dgCMatrix" || inClass == "matrix") {
|
||||||
if (is.null(label)) {
|
if (is.null(label)) {
|
||||||
stop("xgboost: need label when data is a matrix")
|
stop("xgboost: need label when data is a matrix")
|
||||||
}
|
}
|
||||||
dtrain <- xgb.DMatrix(data, label = label)
|
if (is.null(missing)){
|
||||||
|
dtrain <- xgb.DMatrix(data, label = label)
|
||||||
|
} else {
|
||||||
|
dtrain <- xgb.DMatrix(data, label = label, missing = missing)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!is.null(label)) {
|
if (!is.null(label)) {
|
||||||
warning("xgboost: label will be ignored.")
|
warning("xgboost: label will be ignored.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user