[Enhancement] allow base model in xgb.cv
- Dominant language
- C++
- Stars
- 28.8k
- Forks
- 8.9k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 54
Description
The current R function xgb.cv has an inconsistent syntax with xgb.train with respect to a base model. In xgb.cv, xgb_model (like any other ... argument) is passed into the parameter list and silently ignored. It would be nice to support CV-based evaluation of continuing training when starting from a common base model. This would be particularly useful when new features are added after the base model is created.
``` R
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)
param <- list(max_depth = 2, eta = 1, verbose = 0, nthread = 2,objective = "binary:logistic", eval_metric = "auc")
watchlist <- list(train = dtrain)
bst <- xgb.train(param, dtrain,nrounds = 2)
bst2 <- xgb.cv(param, dtrain, nrounds = 2, nfold=5, xgb_model=NULL)
bst3 <- xgb.cv(param, dtrain, nrounds = 2, nfold=5, xgb_model=bst)
## they are the same
print(bst2[["evaluation_log"]])
print(bst3[["evaluation_log"]])
## versus training resumes
bst4 <- xgb.train(param, dtrain,nrounds = 2, watchlist=watchlist , xgb_model=bst)
print(bst4[["evaluation_log"]])
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the R xgb.cv entry point and compare how xgb.train handles xgb_model, confirming where the argument is currently ignored. Use the provided agaricus.train example to verify that cross-validation continues from the supplied base model and produces behavior distinct from training without it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100