[R] Implement feature weights. (#7660)

This commit is contained in:
Jiaming Yuan
2022-02-16 22:20:52 +08:00
committed by GitHub
parent 0149f81a5a
commit 12949c6b31
3 changed files with 37 additions and 4 deletions

View File

@@ -287,6 +287,13 @@ setinfo.xgb.DMatrix <- function(object, name, info, ...) {
.Call(XGDMatrixSetInfo_R, object, name, as.integer(info))
return(TRUE)
}
if (name == "feature_weights") {
if (length(info) != ncol(object)) {
stop("The number of feature weights must equal to the number of columns in the input data")
}
.Call(XGDMatrixSetInfo_R, object, name, as.numeric(info))
return(TRUE)
}
stop("setinfo: unknown info name ", name)
return(FALSE)
}