xgboost (version 0.4-2)

xgb.save: Save xgboost model to binary file

Description

Save xgboost model from xgboost or xgb.train

Usage

xgb.save(model, fname)

Arguments

model
the model object.
fname
the name of the binary file.

Examples

Run this code
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
               eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
xgb.save(bst, 'xgb.model')
bst <- xgb.load('xgb.model')
pred <- predict(bst, test$data)

Run the code above in your browser using DataCamp Workspace