Fix travis build (+1 squashed commit)
Squashed commits: [9240d5f] Fix Travis build
This commit is contained in:
parent
6024480400
commit
5b9e071c18
@ -160,6 +160,8 @@ xgb.iter.update <- function(booster, dtrain, iter, obj = NULL) {
|
|||||||
PACKAGE = "xgboost")
|
PACKAGE = "xgboost")
|
||||||
} else {
|
} else {
|
||||||
pred <- predict(booster, dtrain)
|
pred <- predict(booster, dtrain)
|
||||||
|
gpair <- obj(pred, dtrain)
|
||||||
|
succ <- xgb.iter.boost(booster, dtrain, gpair)
|
||||||
}
|
}
|
||||||
return(TRUE)
|
return(TRUE)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,6 +181,7 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing =
|
|||||||
msg <- list()
|
msg <- list()
|
||||||
for (k in 1:nfold) {
|
for (k in 1:nfold) {
|
||||||
fd <- xgb_folds[[k]]
|
fd <- xgb_folds[[k]]
|
||||||
|
succ <- xgb.iter.update(fd$booster, fd$dtrain, i - 1, obj)
|
||||||
msg[[k]] <- xgb.iter.eval(fd$booster, fd$watchlist, i - 1, feval) %>% str_split("\t") %>% .[[1]]
|
msg[[k]] <- xgb.iter.eval(fd$booster, fd$watchlist, i - 1, feval) %>% str_split("\t") %>% .[[1]]
|
||||||
}
|
}
|
||||||
ret <- xgb.cv.aggcv(msg, showsd)
|
ret <- xgb.cv.aggcv(msg, showsd)
|
||||||
|
|||||||
@ -125,7 +125,7 @@ treeDump <- function(feature_names, text, keepDetail){
|
|||||||
}
|
}
|
||||||
|
|
||||||
linearDump <- function(feature_names, text){
|
linearDump <- function(feature_names, text){
|
||||||
which(text == "weight:") %>% {a <- . + 1; text[a:length(text)]} %>% as.numeric %>% data.table(Feature = feature_names, Weight = .)
|
which(text == "weight:") %>% {a =. + 1; text[a:length(text)]} %>% as.numeric %>% data.table(Feature = feature_names, Weight = .)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Avoid error messages during CRAN check.
|
# Avoid error messages during CRAN check.
|
||||||
|
|||||||
@ -186,6 +186,7 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
|||||||
bestScore <- Inf
|
bestScore <- Inf
|
||||||
}
|
}
|
||||||
bestInd <- 0
|
bestInd <- 0
|
||||||
|
earlyStopflag = FALSE
|
||||||
|
|
||||||
if (length(watchlist) > 1)
|
if (length(watchlist) > 1)
|
||||||
warning('Only the first data set in watchlist is used for early stopping process.')
|
warning('Only the first data set in watchlist is used for early stopping process.')
|
||||||
@ -195,6 +196,7 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
|||||||
bst <- xgb.handleToBooster(handle)
|
bst <- xgb.handleToBooster(handle)
|
||||||
print.every.n <- max( as.integer(print.every.n), 1L)
|
print.every.n <- max( as.integer(print.every.n), 1L)
|
||||||
for (i in 1:nrounds) {
|
for (i in 1:nrounds) {
|
||||||
|
succ <- xgb.iter.update(bst$handle, dtrain, i - 1, obj)
|
||||||
if (length(watchlist) != 0) {
|
if (length(watchlist) != 0) {
|
||||||
msg <- xgb.iter.eval(bst$handle, watchlist, i - 1, feval)
|
msg <- xgb.iter.eval(bst$handle, watchlist, i - 1, feval)
|
||||||
if (0 == ( (i - 1) %% print.every.n))
|
if (0 == ( (i - 1) %% print.every.n))
|
||||||
@ -207,6 +209,7 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
|||||||
bestScore <- score
|
bestScore <- score
|
||||||
bestInd <- i
|
bestInd <- i
|
||||||
} else {
|
} else {
|
||||||
|
earlyStopflag = TRUE
|
||||||
if (i - bestInd >= early.stop.round) {
|
if (i - bestInd >= early.stop.round) {
|
||||||
cat('Stopping. Best iteration:',bestInd)
|
cat('Stopping. Best iteration:',bestInd)
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user