跳到内容

高级接口

高级 XGBoost 接口

xgboost()
拟合 XGBoost 模型
predict(<xgboost>)
计算在新数据上的 XGBoost 模型预测
print(<xgboost>)
打印 XGBoost 模型信息

数据集

R 包附带的测试数据集。

agaricus.train
来自蘑菇数据集的训练部分
agaricus.test
来自蘑菇数据集的测试部分

全局配置

XGBoost 库的全局配置。

xgb.config() `xgb.config<-`()
以 JSON 字符串形式访问模型参数
xgb.set.config() xgb.get.config()
设置和获取全局配置

DMatrix

低级数据存储。

xgb.DMatrix() xgb.QuantileDMatrix()
构造 xgb.DMatrix 对象
xgb.DMatrix.hasinfo()
检查 DMatrix 对象是否具有某个字段
xgb.DMatrix.save()
将 xgb.DMatrix 对象保存到二进制文件
dim(<xgb.DMatrix>)
xgb.DMatrix 的维度
dimnames(<xgb.DMatrix>) `dimnames<-`(<xgb.DMatrix>)
处理 xgb.DMatrix 的列名
print(<xgb.DMatrix>)
打印 xgb.DMatrix
xgb.DataBatch()
数据批次结构
xgb.DataIter()
XGBoost 数据迭代器
xgb.get.DMatrix.data()
获取 DMatrix 数据
xgb.get.DMatrix.num.non.missing()
获取 DMatrix 中非缺失条目的数量
xgb.ExtMemDMatrix()
来自外部数据的 DMatrix
xgb.QuantileDMatrix.from_iterator()
来自外部数据的 QuantileDMatrix
xgb.get.DMatrix.qcut()
获取 DMatrix 中的分位数切点
xgb.slice.DMatrix() `[`(<xgb.DMatrix>)
切片 DMatrix

Booster

XGBoost 的模型。

a-compatibility-note-for-saveRDS-save
模型序列化和兼容性
coef(<xgb.Booster>)
从线性 Booster 中提取系数
getinfo() setinfo()
获取或设置 xgb.DMatrix 和 xgb.Booster 对象的信息
predict(<xgb.Booster>)
XGBoost 模型的预测方法
print(<xgb.Booster>)
打印 xgb.Booster
xgb.load()
从二进制文件加载 XGBoost 模型
xgb.load.raw()
从 R 的原始向量加载序列化的 XGBoost 模型
xgb.save()
将 XGBoost 模型保存到二进制文件
xgb.save.raw()
将 XGBoost 模型保存到 R 的原始向量
xgb.copy.Booster()
深度复制 Booster 对象
xgb.slice.Booster() `[`(<xgb.Booster>)
按轮次切片 Booster
xgb.get.num.boosted.rounds() length(<xgb.Booster>)
获取已拟合 Booster 中的提升次数
xgb.is.same.Booster()
检查两个 Booster 是否共享同一个 C 对象
xgb.importance()
特征重要性
xgb.attr() `xgb.attr<-`() xgb.attributes() `xgb.attributes<-`()
访问模型的序列化属性
xgb.create.features()
从先前学习到的模型创建新特征
xgb.model.dt.tree()
解析模型文本转储
`xgb.model.parameters<-`()
访问模型参数
xgb.ggplot.deepness() xgb.plot.deepness()
绘制模型树深度
xgb.dump()
以文本格式转储 XGBoost 模型。
variable.names(<xgb.Booster>)
从 Booster 中获取特征名称
xgb.ggplot.importance() xgb.plot.importance()
绘制特征重要性
xgb.plot.multi.trees()
将所有树投影到一棵树上
xgb.plot.shap()
SHAP 依赖图
xgb.ggplot.shap.summary() xgb.plot.shap.summary()
SHAP 摘要图
xgb.plot.tree()
绘制提升树
xgb.gblinear.history()
提取 gblinear 系数历史记录

训练回调

用于训练的回调函数。

xgb.Callback()
XGBoost 回调构造器
xgb.cb.cv.predict()
返回基于交叉验证的预测的回调
xgb.cb.early.stop()
激活提前停止的回调
xgb.cb.evaluation.log()
记录评估历史的回调
xgb.cb.gblinear.history()
收集 gblinear Booster 系数历史的回调
xgb.cb.print.evaluation()
打印评估结果的回调
xgb.cb.reset.parameters()
在每次迭代时重置 Booster 参数的回调
xgb.cb.save.model()
保存模型文件的回调

低级训练函数

使用 DMatrix 和 Booster 的低级训练函数

xgb.params()
XGBoost 参数
xgb.train()
拟合 XGBoost 模型
xgb.cv()
交叉验证
print(<xgb.cv.synchronous>)
打印 xgb.cv 结果

弃用设置

xgboost-options
XGBoost 选项