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

@@ -22,7 +22,10 @@ xgb.save <- function(model, fname) {
stop("xgb.save: fname must be character")
}
if (class(model) == "xgb.Booster") {
.Call("XGBoosterSaveModel_R", model, fname, PACKAGE = "xgboost")
if (is.null(model$handle)) {
model$handle <- xgb.load(model$raw)
}
.Call("XGBoosterSaveModel_R", model$handle, fname, PACKAGE = "xgboost")
return(TRUE)
}
stop("xgb.save: the input must be xgb.Booster. Use xgb.DMatrix.save to save