根据用例,有多种方法可以序列化 Booster 对象。更多...
|  | 
| int | XGBoosterLoadModel (BoosterHandle handle, const char *fname) | 
|  | 从现有文件加载模型。更多... 
 | 
|  | 
| int | XGBoosterSaveModel (BoosterHandle handle, const char *fname) | 
|  | 将模型保存到现有文件。更多... 
 | 
|  | 
| int | XGBoosterLoadModelFromBuffer (BoosterHandle handle, const void *buf, bst_ulong len) | 
|  | 从内存缓冲区加载模型 更多... 
 | 
|  | 
| int | XGBoosterSaveModelToBuffer (BoosterHandle handle, char const *config, bst_ulong *out_len, char const **out_dptr) | 
|  | 将模型保存为原始字节,返回数组的头部。用户必须在下一次 xgboost 调用之前复制结果。更多... 
 | 
|  | 
| int | XGBoosterSerializeToBuffer (BoosterHandle handle, bst_ulong *out_len, const char **out_dptr) | 
|  | 基于内存快照的序列化方法。将所有状态保存到缓冲区。更多... 
 | 
|  | 
| int | XGBoosterUnserializeFromBuffer (BoosterHandle handle, const void *buf, bst_ulong len) | 
|  | 基于内存快照的序列化方法。加载从 XGBoosterSerializeToBuffer 返回的缓冲区。更多... 
 | 
|  | 
| int | XGBoosterSaveJsonConfig (BoosterHandle handle, bst_ulong *out_len, char const **out_str) | 
|  | 将 XGBoost 的内部配置保存到 JSON 文档中。目前支持是实验性的,函数签名将来可能在不通知的情况下更改。更多... 
 | 
|  | 
| int | XGBoosterLoadJsonConfig (BoosterHandle handle, char const *config) | 
|  | 从 JSON 文档加载 XGBoost 的内部配置。目前支持是实验性的,函数签名将来可能在不通知的情况下更改。更多... 
 | 
|  | 
根据用例,有多种方法可以序列化 Booster 对象。
序列化 API 简要说明。有 3 组不同的序列化 API。
- 带有“Model”一词的函数处理保存/加载 XGBoost 模型,如树或线性权重。剥离参数配置,如训练算法或 CUDA 设备 ID。这些函数旨在让用户将训练好的模型用于不同的任务,例如预测、继续训练或模型解释。
- 带有“Config”一词的函数处理保存/加载配置。它帮助用户研究 XGBoost 的内部。用户还可以使用加载方法以结构化方式指定参数。这些函数在 1.0.0 中引入,但尚未稳定。
- 带有“Serialization”一词的函数是上述两者的结合。它们用于检查点或在分布式环境中继续训练任务等情况。在这些情况下,任务必须在没有任何用户干预的情况下执行。
◆ XGBoosterLoadJsonConfig()
      
        
          | int XGBoosterLoadJsonConfig | ( | BoosterHandle | handle, | 
        
          |  |  | char const * | config | 
        
          |  | ) |  |  | 
      
 
从 JSON 文档加载 XGBoost 的内部配置。目前支持是实验性的,函数签名将来可能在不通知的情况下更改。
- 参数
- 
  
    | handle | Booster 对象的句柄。 |  | config | JSON 文档的字符串表示。 |  
 
- 返回
- 成功返回 0,失败返回 -1
 
 
◆ XGBoosterLoadModel()
      
        
          | int XGBoosterLoadModel | ( | BoosterHandle | handle, | 
        
          |  |  | const char * | fname | 
        
          |  | ) |  |  | 
      
 
从现有文件加载模型。
- 参数
- 
  
    | handle | handle |  | fname | 文件名。字符串必须是 UTF-8 编码。 |  
 
- 返回
- 成功返回 0,失败返回 -1
- 示例
- inference.c.
 
 
◆ XGBoosterLoadModelFromBuffer()
从内存缓冲区加载模型
- 参数
- 
  
    | handle | handle |  | buf | 指向缓冲区的指针 |  | 长度 | 缓冲区的长度 |  
 
- 返回
- 成功返回 0,失败返回 -1
 
 
◆ XGBoosterSaveJsonConfig()
将 XGBoost 的内部配置保存到 JSON 文档中。目前支持是实验性的,函数签名将来可能在不通知的情况下更改。
- 参数
- 
  
    | handle | Booster 对象的句柄。 |  | out_len | 输出字符串的长度 |  | out_str | 指向字符数组的有效指针。字符数组由 XGBoost 分配和管理,而指向该数组的指针需要由调用者管理。 |  
 
- 返回
- 成功返回 0,失败返回 -1
 
 
◆ XGBoosterSaveModel()
      
        
          | int XGBoosterSaveModel | ( | BoosterHandle | handle, | 
        
          |  |  | const char * | fname | 
        
          |  | ) |  |  | 
      
 
 
◆ XGBoosterSaveModelToBuffer()
      
        
          | int XGBoosterSaveModelToBuffer | ( | BoosterHandle | handle, | 
        
          |  |  | char const * | config, | 
        
          |  |  | bst_ulong * | out_len, | 
        
          |  |  | char const ** | out_dptr | 
        
          |  | ) |  |  | 
      
 
将模型保存为原始字节,返回数组的头部。用户必须在下一次 xgboost 调用之前复制结果。
- 参数
- 
  
    | handle | handle |  | config | JSON 编码的字符串,存储函数的参数。JSON 文档中预期有以下键 
"format": str
json:输出 booster 将被编码为 JSON。ubj:输出 booster 将被编码为通用二进制 JSON。此格式除兼容性原因外。 |  | out_len | 用于保存输出长度的参数 |  | out_dptr | 用于保存输出数据指针的参数 |  
 
- 返回
- 成功返回 0,失败返回 -1
 
 
◆ XGBoosterSerializeToBuffer()
基于内存快照的序列化方法。将所有状态保存到缓冲区中。
- 参数
- 
  
    | handle | handle |  | out_len | 用于保存输出长度的参数 |  | out_dptr | 用于保存输出数据指针的参数 |  
 
- 返回
- 成功返回 0,失败返回 -1
 
 
◆ XGBoosterUnserializeFromBuffer()