@@ -410,7 +410,7 @@ xgb.createFolds <- function(y, k) {
410
410
# ' At this time, some of the parameter names were changed in order to make the code style more uniform.
411
411
# ' The deprecated parameters would be removed in the next release.
412
412
# '
413
- # ' To see all the current deprecated and new parameters, check the \code{ xgboost:::depr_par_lut} table.
413
+ # ' To see all the current deprecated and new parameters, check the ` xgboost:::depr_par_lut` table.
414
414
# '
415
415
# ' A deprecation warning is shown when any of the deprecated parameters is used in a call.
416
416
# ' An additional warning is shown when there was a partial match to a deprecated parameter
@@ -419,70 +419,79 @@ xgb.createFolds <- function(y, k) {
419
419
# ' @name xgboost-deprecated
420
420
NULL
421
421
422
- # ' @title Model Serialization and Compatibility
423
- # ' @description
422
+ # ' Model Serialization and Compatibility
424
423
# '
424
+ # ' @description
425
425
# ' When it comes to serializing XGBoost models, it's possible to use R serializers such as
426
- # ' \link{ save} or \link{ saveRDS} to serialize an XGBoost R model, but XGBoost also provides
426
+ # ' [ save()] or [ saveRDS()] to serialize an XGBoost R model, but XGBoost also provides
427
427
# ' its own serializers with better compatibility guarantees, which allow loading
428
428
# ' said models in other language bindings of XGBoost.
429
429
# '
430
- # ' Note that an `xgb.Booster` object, outside of its core components, might also keep:\itemize{
431
- # ' \item Additional model configuration (accessible through \link{xgb.config}),
432
- # ' which includes model fitting parameters like `max_depth` and runtime parameters like `nthread`.
433
- # ' These are not necessarily useful for prediction/importance/plotting.
434
- # ' \item Additional R-specific attributes - e.g. results of callbacks, such as evaluation logs,
435
- # ' which are kept as a `data.table` object, accessible through `attributes(model)$evaluation_log`
436
- # ' if present.
437
- # ' }
430
+ # ' Note that an `xgb.Booster` object, outside of its core components, might also keep:
431
+ # ' - Additional model configuration (accessible through [xgb.config()]), which includes
432
+ # ' model fitting parameters like `max_depth` and runtime parameters like `nthread`.
433
+ # ' These are not necessarily useful for prediction/importance/plotting.
434
+ # ' - Additional R specific attributes - e.g. results of callbacks, such as evaluation logs,
435
+ # ' which are kept as a `data.table` object, accessible through
436
+ # ' `attributes(model)$evaluation_log` if present.
438
437
# '
439
438
# ' The first one (configurations) does not have the same compatibility guarantees as
440
- # ' the model itself, including attributes that are set and accessed through \link{xgb.attributes} - that is, such configuration
441
- # ' might be lost after loading the booster in a different XGBoost version, regardless of the
442
- # ' serializer that was used. These are saved when using \link{saveRDS}, but will be discarded
443
- # ' if loaded into an incompatible XGBoost version. They are not saved when using XGBoost's
444
- # ' serializers from its public interface including \link{xgb.save} and \link{xgb.save.raw}.
439
+ # ' the model itself, including attributes that are set and accessed through
440
+ # ' [xgb.attributes()] - that is, such configuration might be lost after loading the
441
+ # ' booster in a different XGBoost version, regardless of the serializer that was used.
442
+ # ' These are saved when using [saveRDS()], but will be discarded if loaded into an
443
+ # ' incompatible XGBoost version. They are not saved when using XGBoost's
444
+ # ' serializers from its public interface including [xgb.save()] and [xgb.save.raw()].
445
445
# '
446
- # ' The second ones (R attributes) are not part of the standard XGBoost model structure, and thus are
447
- # ' not saved when using XGBoost's own serializers. These attributes are only used for informational
448
- # ' purposes, such as keeping track of evaluation metrics as the model was fit, or saving the R
449
- # ' call that produced the model, but are otherwise not used for prediction / importance / plotting / etc.
446
+ # ' The second ones (R attributes) are not part of the standard XGBoost model structure,
447
+ # ' and thus are not saved when using XGBoost's own serializers. These attributes are
448
+ # ' only used for informational purposes, such as keeping track of evaluation metrics as
449
+ # ' the model was fit, or saving the R call that produced the model, but are otherwise
450
+ # ' not used for prediction / importance / plotting / etc.
450
451
# ' These R attributes are only preserved when using R's serializers.
451
452
# '
452
- # ' Note that XGBoost models in R starting from version `2.1.0` and onwards, and XGBoost models
453
- # ' before version `2.1.0`; have a very different R object structure and are incompatible with
454
- # ' each other. Hence, models that were saved with R serializers live `saveRDS` or `save` before
455
- # ' version `2.1.0` will not work with latter `xgboost` versions and vice versa. Be aware that
456
- # ' the structure of R model objects could in theory change again in the future, so XGBoost's serializers
453
+ # ' Note that XGBoost models in R starting from version `2.1.0` and onwards, and
454
+ # ' XGBoost models before version `2.1.0`; have a very different R object structure and
455
+ # ' are incompatible with each other. Hence, models that were saved with R serializers
456
+ # ' like [saveRDS()] or [save()] before version `2.1.0` will not work with latter
457
+ # ' `xgboost` versions and vice versa. Be aware that the structure of R model objects
458
+ # ' could in theory change again in the future, so XGBoost's serializers
457
459
# ' should be preferred for long-term storage.
458
460
# '
459
- # ' Furthermore, note that using the package `qs` for serialization will require version 0.26 or
460
- # ' higher of said package, and will have the same compatibility restrictions as R serializers.
461
+ # ' Furthermore, note that using the package `qs` for serialization will require
462
+ # ' version 0.26 or higher of said package, and will have the same compatibility
463
+ # ' restrictions as R serializers.
461
464
# '
462
465
# ' @details
463
- # ' Use \code{\link{ xgb.save}} to save the XGBoost model as a stand-alone file. You may opt into
466
+ # ' Use [ xgb.save()] to save the XGBoost model as a stand-alone file. You may opt into
464
467
# ' the JSON format by specifying the JSON extension. To read the model back, use
465
- # ' \code{\link{ xgb.load}} .
468
+ # ' [ xgb.load()] .
466
469
# '
467
- # ' Use \code{\link{ xgb.save.raw}} to save the XGBoost model as a sequence (vector) of raw bytes
470
+ # ' Use [ xgb.save.raw()] to save the XGBoost model as a sequence (vector) of raw bytes
468
471
# ' in a future-proof manner. Future releases of XGBoost will be able to read the raw bytes and
469
- # ' re-construct the corresponding model. To read the model back, use \code{\link{ xgb.load.raw}} .
470
- # ' The \code{\link{ xgb.save.raw}} function is useful if you'd like to persist the XGBoost model
472
+ # ' re-construct the corresponding model. To read the model back, use [ xgb.load.raw()] .
473
+ # ' The [ xgb.save.raw()] function is useful if you would like to persist the XGBoost model
471
474
# ' as part of another R object.
472
475
# '
473
- # ' Use \link{ saveRDS} if you require the R-specific attributes that a booster might have, such
476
+ # ' Use [ saveRDS()] if you require the R-specific attributes that a booster might have, such
474
477
# ' as evaluation logs, but note that future compatibility of such objects is outside XGBoost's
475
478
# ' control as it relies on R's serialization format (see e.g. the details section in
476
- # ' \link{ serialize} and \link{ save} from base R).
479
+ # ' [ serialize] and [ save()] from base R).
477
480
# '
478
481
# ' For more details and explanation about model persistence and archival, consult the page
479
482
# ' \url{https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html}.
480
483
# '
481
484
# ' @examples
482
- # ' data(agaricus.train, package='xgboost')
483
- # ' bst <- xgb.train(data = xgb.DMatrix(agaricus.train$data, label = agaricus.train$label),
484
- # ' max_depth = 2, eta = 1, nthread = 2, nrounds = 2,
485
- # ' objective = "binary:logistic")
485
+ # ' data(agaricus.train, package = "xgboost")
486
+ # '
487
+ # ' bst <- xgb.train(
488
+ # ' data = xgb.DMatrix(agaricus.train$data, label = agaricus.train$label),
489
+ # ' max_depth = 2,
490
+ # ' eta = 1,
491
+ # ' nthread = 2,
492
+ # ' nrounds = 2,
493
+ # ' objective = "binary:logistic"
494
+ # ' )
486
495
# '
487
496
# ' # Save as a stand-alone file; load it with xgb.load()
488
497
# ' fname <- file.path(tempdir(), "xgb_model.ubj")
0 commit comments