The following code works perfectly well if called by source command. It is part of a function where xgb.metric.label
is a formal parameter that at run time can be valorized with values like "rmsle"
. bst.cv
is a data.table
.
lab = paste('test.',xgb.metric.label,'.mean',sep='')
bst.cv = xgboost::xgb.cv(param=param, data = data, label = y,
nfold = nfold, nrounds=cv.nround , folds = foldList,
feval = xgb.metric.fun , maximize = xgb.maximize, verbose=FALSE)
if (verbose) print(bst.cv)
early.stop = which(bst.cv[,get(lab)] == bst.cv[,min(get(lab))] )
On the contrary when I call such a code by R CMD check R-package --as-cran
I got the following error Error in get(lab) : object 'test.rmsle.mean' not found
. But from the standard output I can see perfectly well test.rmsle.mean
exists.
>> xgb: cross-validation ...
train.rmsle.mean train.rmsle.std test.rmsle.mean test.rmsle.std
1: 1.982000 0.047535 1.971343 0.257277
2: 1.957587 0.047260 1.947059 0.255464
3: 1.933816 0.046985 1.923421 0.253643
4: 1.910654 0.046711 1.900397 0.251813
5: 1.888074 0.046436 1.877959 0.249975
---
2996: 0.267519 0.072264 0.307539 0.239068
2997: 0.267531 0.072254 0.307413 0.239195
2998: 0.267425 0.072160 0.307183 0.239163
2999: 0.267488 0.072168 0.307137 0.239798
3000: 0.267476 0.072201 0.307264 0.239906
I tried to call all the related libraries a line before the error, but without success.
library(data.table)
library(xgboost)
library(methods)
I also added these libraries in the imports section of DESCRIPTION
file. Again, without success.
Imports:
parallel,
subselect,
plyr,
xgboost,
methods,
data.table
Why are you using get
at all?
There is no need to incur the overhead....
which(bst.cv[[lab]] == min(bst.cv[[lab]]))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.