check duplicated params
This commit is contained in:
parent
7cb449c4a7
commit
c51d71b033
@ -112,7 +112,12 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing =
|
|||||||
} else {
|
} else {
|
||||||
dtrain <- xgb.get.DMatrix(data, label, missing)
|
dtrain <- xgb.get.DMatrix(data, label, missing)
|
||||||
}
|
}
|
||||||
params <- append(params, list(...))
|
dot.params = list(...)
|
||||||
|
nms.params = names(params)
|
||||||
|
nms.dot.params = names(dot.params)
|
||||||
|
if (length(intersect(nms.params,nms.dot.params))>0)
|
||||||
|
stop("Duplicated defined term in parameters. Please check your list of params.")
|
||||||
|
params <- append(params, dot.params)
|
||||||
params <- append(params, list(silent=1))
|
params <- append(params, list(silent=1))
|
||||||
for (mc in metrics) {
|
for (mc in metrics) {
|
||||||
params <- append(params, list("eval_metric"=mc))
|
params <- append(params, list("eval_metric"=mc))
|
||||||
@ -126,8 +131,8 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing =
|
|||||||
obj = params$objective
|
obj = params$objective
|
||||||
params[['objective']] = NULL
|
params[['objective']] = NULL
|
||||||
}
|
}
|
||||||
if (!is.null(params$eval_metric) && !is.null(feval))
|
# if (!is.null(params$eval_metric) && !is.null(feval))
|
||||||
stop("xgb.cv: cannot assign two different evaluation metrics")
|
# stop("xgb.cv: cannot assign two different evaluation metrics")
|
||||||
if (!is.null(params$eval_metric))
|
if (!is.null(params$eval_metric))
|
||||||
if (class(params$eval_metric)=='function') {
|
if (class(params$eval_metric)=='function') {
|
||||||
feval = params$eval_metric
|
feval = params$eval_metric
|
||||||
|
|||||||
@ -136,7 +136,13 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
|||||||
if (length(watchlist) != 0 && verbose == 0) {
|
if (length(watchlist) != 0 && verbose == 0) {
|
||||||
warning('watchlist is provided but verbose=0, no evaluation information will be printed')
|
warning('watchlist is provided but verbose=0, no evaluation information will be printed')
|
||||||
}
|
}
|
||||||
params = append(params, list(...))
|
|
||||||
|
dot.params = list(...)
|
||||||
|
nms.params = names(params)
|
||||||
|
nms.dot.params = names(dot.params)
|
||||||
|
if (length(intersect(nms.params,nms.dot.params))>0)
|
||||||
|
stop("Duplicated term in parameters. Please check your list of params.")
|
||||||
|
params = append(params, dot.params)
|
||||||
|
|
||||||
# customized objective and evaluation metric interface
|
# customized objective and evaluation metric interface
|
||||||
if (!is.null(params$objective) && !is.null(obj))
|
if (!is.null(params$objective) && !is.null(obj))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user