Fix travis build (+1 squashed commit)
Squashed commits: [9240d5f] Fix Travis build
This commit is contained in:
parent
6024480400
commit
5b9e071c18
@ -1,4 +1,4 @@
|
||||
#' @importClassesFrom Matrix dgCMatrix dgeMatrix
|
||||
#' @importClassesFrom Matrix dgCMatrix dgeMatrix
|
||||
#' @import methods
|
||||
|
||||
# depends on matrix
|
||||
@ -160,6 +160,8 @@ xgb.iter.update <- function(booster, dtrain, iter, obj = NULL) {
|
||||
PACKAGE = "xgboost")
|
||||
} else {
|
||||
pred <- predict(booster, dtrain)
|
||||
gpair <- obj(pred, dtrain)
|
||||
succ <- xgb.iter.boost(booster, dtrain, gpair)
|
||||
}
|
||||
return(TRUE)
|
||||
}
|
||||
|
||||
@ -181,6 +181,7 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing =
|
||||
msg <- list()
|
||||
for (k in 1:nfold) {
|
||||
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]]
|
||||
}
|
||||
ret <- xgb.cv.aggcv(msg, showsd)
|
||||
|
||||
@ -125,7 +125,7 @@ treeDump <- function(feature_names, text, keepDetail){
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
@ -186,6 +186,7 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
||||
bestScore <- Inf
|
||||
}
|
||||
bestInd <- 0
|
||||
earlyStopflag = FALSE
|
||||
|
||||
if (length(watchlist) > 1)
|
||||
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)
|
||||
print.every.n <- max( as.integer(print.every.n), 1L)
|
||||
for (i in 1:nrounds) {
|
||||
succ <- xgb.iter.update(bst$handle, dtrain, i - 1, obj)
|
||||
if (length(watchlist) != 0) {
|
||||
msg <- xgb.iter.eval(bst$handle, watchlist, i - 1, feval)
|
||||
if (0 == ( (i - 1) %% print.every.n))
|
||||
@ -207,6 +209,7 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
|
||||
bestScore <- score
|
||||
bestInd <- i
|
||||
} else {
|
||||
earlyStopflag = TRUE
|
||||
if (i - bestInd >= early.stop.round) {
|
||||
cat('Stopping. Best iteration:',bestInd)
|
||||
break
|
||||
|
||||
@ -11,7 +11,7 @@ df <- data.table(Arthritis, keep.rownames = F)
|
||||
df[,AgeDiscret := as.factor(round(Age / 10,0))]
|
||||
df[,AgeCat := as.factor(ifelse(Age > 30, "Old", "Young"))]
|
||||
df[,ID := NULL]
|
||||
sparse_matrix <- sparse.model.matrix(Improved ~ . -1, data = df)
|
||||
sparse_matrix <- sparse.model.matrix(Improved~.-1, data = df)
|
||||
output_vector <- df[,Y := 0][Improved == "Marked",Y := 1][,Y]
|
||||
bst <- xgboost(data = sparse_matrix, label = output_vector, max.depth = 9,
|
||||
eta = 1, nthread = 2, nround = 10,objective = "binary:logistic")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user