Debian Codegraph @

man/xgb.save.raw.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/xgb.save.raw.R
3 \name{xgb.save.raw}
4 \alias{xgb.save.raw}
5 \title{Save XGBoost model to R's raw vector}
6 \usage{
7 xgb.save.raw(model, raw_format = "ubj")
8 }
9 \arguments{
10 \item{model}{The model object.}
11
12 \item{raw_format}{The format for encoding the booster:
13 \itemize{
14 \item "json": Encode the booster into JSON text document.
15 \item "ubj": Encode the booster into Universal Binary JSON.
16 \item "deprecated": Encode the booster into old customized binary format.
17 }}
18 }
19 \description{
20 Save XGBoost model from \code{\link[=xgboost]{xgboost()}} or \code{\link[=xgb.train]{xgb.train()}}.
21 Call \code{\link[=xgb.load.raw]{xgb.load.raw()}} to load the model back from raw vector.
22 }
23 \examples{
24 \dontshow{RhpcBLASctl::omp_set_num_threads(1)}
25 data(agaricus.train, package = "xgboost")
26 data(agaricus.test, package = "xgboost")
27
28 ## Keep the number of threads to 1 for examples
29 nthread <- 1
30 data.table::setDTthreads(nthread)
31
32 train <- agaricus.train
33 test <- agaricus.test
34
35 bst <- xgb.train(
36 data = xgb.DMatrix(train$data, label = train$label, nthread = 1),
37 nrounds = 2,
38 params = xgb.params(
39 max_depth = 2,
40 nthread = nthread,
41 objective = "binary:logistic"
42 )
43 )
44
45 raw <- xgb.save.raw(bst)
46 bst <- xgb.load.raw(raw)
47
48 }