add handle and raw structure to xgb.Booster

This commit is contained in:
hetong007
2015-02-09 15:51:24 -08:00
parent ea5860d574
commit 5b611c355e
7 changed files with 46 additions and 16 deletions

View File

@@ -86,13 +86,16 @@ xgb.train <- function(params=list(), data, nrounds, watchlist = list(),
}
params = append(params, list(...))
bst <- xgb.Booster(params, append(watchlist, dtrain))
bst <- list(handle = NULL,raw = NULL)
class(bst) <- 'xgb.Booster'
bst$handle <- xgb.Booster(params, append(watchlist, dtrain))
for (i in 1:nrounds) {
succ <- xgb.iter.update(bst, dtrain, i - 1, obj)
succ <- xgb.iter.update(bst$handle, dtrain, i - 1, obj)
if (length(watchlist) != 0) {
msg <- xgb.iter.eval(bst, watchlist, i - 1, feval)
msg <- xgb.iter.eval(bst$handle, watchlist, i - 1, feval)
cat(paste(msg, "\n", sep=""))
}
}
bst$raw <- xgb.save.raw(bst$handle)
return(bst)
}