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:
430
+ # ' Note that an `xgb.Booster` object (**as produced by [xgb.train()]**, see rest of the doc
431
+ # ' for objects produced by [xgboost()]), outside of its core components, might also keep:
431
432
# ' - Additional model configuration (accessible through [xgb.config()]), which includes
432
433
# ' model fitting parameters like `max_depth` and runtime parameters like `nthread`.
433
434
# ' These are not necessarily useful for prediction/importance/plotting.
@@ -450,6 +451,16 @@ NULL
450
451
# ' not used for prediction / importance / plotting / etc.
451
452
# ' These R attributes are only preserved when using R's serializers.
452
453
# '
454
+ # ' In addition to the regular `xgb.Booster` objects producted by [xgb.train()], the
455
+ # ' function [xgboost()] produces a different subclass `xgboost`, which keeps other
456
+ # ' additional metadata as R attributes such as class names in classification problems,
457
+ # ' and which has a dedicated `predict` method that uses different defaults. XGBoost's
458
+ # ' own serializers can work with this `xgboost` class, but as they do not keep R
459
+ # ' attributes, the resulting object, when deserialized, is downcasted to the regular
460
+ # ' `xgb.Booster` class (i.e. it loses the metadata, and the resulting object will use
461
+ # ' `predict.xgb.Booster` instead of `predict.xgboost`) - for these `xgboost` objects,
462
+ # ' `saveRDS` might thus be a better option if the extra functionalities are needed.
463
+ # '
453
464
# ' Note that XGBoost models in R starting from version `2.1.0` and onwards, and
454
465
# ' XGBoost models before version `2.1.0`; have a very different R object structure and
455
466
# ' are incompatible with each other. Hence, models that were saved with R serializers
474
485
# ' as part of another R object.
475
486
# '
476
487
# ' Use [saveRDS()] if you require the R-specific attributes that a booster might have, such
477
- # ' as evaluation logs, but note that future compatibility of such objects is outside XGBoost's
478
- # ' control as it relies on R 's serialization format (see e.g. the details section in
479
- # ' [serialize] and [save()] from base R).
488
+ # ' as evaluation logs or the model class `xgboost` instead of `xgb.Booster`, but note that
489
+ # ' future compatibility of such objects is outside XGBoost 's control as it relies on R's
490
+ # ' serialization format (see e.g. the details section in [serialize] and [save()] from base R).
480
491
# '
481
492
# ' For more details and explanation about model persistence and archival, consult the page
482
493
# ' \url{https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html}.
0 commit comments