[R] remove uses of exists() (#6387)
This commit is contained in:
parent
3ac173fc8b
commit
3cca1c5fa1
@ -191,9 +191,8 @@ xgb.iter.eval <- function(booster_handle, watchlist, iter, feval = NULL) {
|
|||||||
generate.cv.folds <- function(nfold, nrows, stratified, label, params) {
|
generate.cv.folds <- function(nfold, nrows, stratified, label, params) {
|
||||||
|
|
||||||
# cannot do it for rank
|
# cannot do it for rank
|
||||||
if (exists('objective', where = params) &&
|
objective <- params$objective
|
||||||
is.character(params$objective) &&
|
if (is.character(objective) && strtrim(objective, 5) == 'rank:') {
|
||||||
strtrim(params$objective, 5) == 'rank:') {
|
|
||||||
stop("\n\tAutomatic generation of CV-folds is not implemented for ranking!\n",
|
stop("\n\tAutomatic generation of CV-folds is not implemented for ranking!\n",
|
||||||
"\tConsider providing pre-computed CV-folds through the 'folds=' parameter.\n")
|
"\tConsider providing pre-computed CV-folds through the 'folds=' parameter.\n")
|
||||||
}
|
}
|
||||||
@ -206,8 +205,7 @@ generate.cv.folds <- function(nfold, nrows, stratified, label, params) {
|
|||||||
# - For classification, need to convert y labels to factor before making the folds,
|
# - For classification, need to convert y labels to factor before making the folds,
|
||||||
# and then do stratification by factor levels.
|
# and then do stratification by factor levels.
|
||||||
# - For regression, leave y numeric and do stratification by quantiles.
|
# - For regression, leave y numeric and do stratification by quantiles.
|
||||||
if (exists('objective', where = params) &&
|
if (is.character(objective)) {
|
||||||
is.character(params$objective)) {
|
|
||||||
# If 'objective' provided in params, assume that y is a classification label
|
# If 'objective' provided in params, assume that y is a classification label
|
||||||
# unless objective is reg:squarederror
|
# unless objective is reg:squarederror
|
||||||
if (params$objective != 'reg:squarederror')
|
if (params$objective != 'reg:squarederror')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user