fix cv attr
This commit is contained in:
parent
f75387f701
commit
5188bad873
@ -28,6 +28,18 @@ setMethod("slice", signature = "xgb.DMatrix",
|
|||||||
if (class(object) != "xgb.DMatrix") {
|
if (class(object) != "xgb.DMatrix") {
|
||||||
stop("slice: first argument dtrain must be xgb.DMatrix")
|
stop("slice: first argument dtrain must be xgb.DMatrix")
|
||||||
}
|
}
|
||||||
ret <- .Call("XGDMatrixSliceDMatrix_R", object, idxset, PACKAGE = "xgboost")
|
ret <- .Call("XGDMatrixSliceDMatrix_R", object, idxset,
|
||||||
|
PACKAGE = "xgboost")
|
||||||
|
|
||||||
|
attr_list <- attributes(object)
|
||||||
|
nr <- xgb.numrow(object)
|
||||||
|
len <- sapply(attr_list,length)
|
||||||
|
ind <- which(len==nr)
|
||||||
|
if (length(ind)>0) {
|
||||||
|
nms <- names(attr_list)[ind]
|
||||||
|
for (i in 1:length(ind)) {
|
||||||
|
attr(ret,nms[i]) <- attr(object,nms[i])[idxset]
|
||||||
|
}
|
||||||
|
}
|
||||||
return(structure(ret, class = "xgb.DMatrix"))
|
return(structure(ret, class = "xgb.DMatrix"))
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user