1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! XGBoost JSON/UBJSON schema mapping. User docs: [XGBoost interchange](super#xgboost-interchange).
use crateHessboostError;
use crateResult;
use crateBoostedModel;
use crateubjson;
use ;
/// Serialize a [`BoostedModel`] into XGBoost's JSON model schema.
///
/// The result is a pretty-printed JSON string equivalent to what
/// `xgboost.Booster.save_model("m.json")` produces for a `gbtree` model
/// (including DART tree weights as `weight_drop`), and is accepted by
/// [`import_xgboost_json`] as well as upstream XGBoost 3.4.2. See the module
/// docs (above) for the `base_score` space convention.
/// Serialize a [`BoostedModel`] into XGBoost's UBJSON model format.
///
/// The bytes hold the same document as [`export_xgboost_json`], encoded the
/// way `xgboost.Booster.save_model("m.ubj")` encodes it (typed tree arrays;
/// see [UBJSON encoding](self#ubjson-encoding)). They are accepted by
/// [`import_xgboost_ubjson`] and upstream XGBoost 3.4.2.
/// Parse an XGBoost JSON model document into a [`BoostedModel`].
///
/// Accepts `gbtree` boosters, including XGBoost 3.4.1's DART layout
/// (`gbtree` plus `model.weight_drop`). Other booster kinds produce a
/// [`HessboostError::ModelFormat`]. See the module docs (above) for details and
/// the `base_score` space convention.
/// Parse an XGBoost UBJSON model (`save_model("m.ubj")` or
/// `save_raw("ubj")`) into a [`BoostedModel`].
///
/// Decoding accepts optimized (typed / counted) and plain UBJSON containers;
/// the decoded document then goes through the same mapping, with the same
/// support and errors, as [`import_xgboost_json`]. Malformed bytes produce a
/// [`HessboostError::ModelFormat`].