R's xgb.cv does not process weights properly
- Dominant language
- C++
- Stars
- 28.8k
- Forks
- 8.9k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 54
Description
When I try to use a custom loss function with xgb.cv, the weights don't get passed properly. In the sample code below, xgboost works fine. xgb.cv however returns all NaNs. If you debug the eval_error function you'll notice that the dtrain object does not have a weights attribute like it does when using the xgboost function. This is also true if I wrap the weight argument in the params argument.
```
X <- matrix(rnorm(1000), ncol = 2)
y <- rnorm(500)
w <- runif(500)
eval_error <- function(preds, dtrain) {
labels <- getinfo(dtrain, "label")
weights <- getinfo(dtrain, 'weight')
error <- mean((labels - weights)^2)
return(list(metric = 'error', value = error))
}
xgb_cv <- xgb.cv(data = X, label = y, weight = w, nrounds = 50, eval_metric = eval_error, nfold = 4)
xgb <- xgboost(data = X, label = y, weight = w, nrounds = 50, eval_metric = eval_error)
```
I am running:
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS
XGBoost version 1.1.1.1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.