xgboost
公共成员函数 | 静态公共成员函数 | 保护成员函数 | 保护属性 | 所有成员列表
xgboost::GradientBooster 类参考抽象

梯度提升模型的接口。 更多...

#include <gbm.h>

xgboost::GradientBooster 的继承图
Inheritance graph
xgboost::GradientBooster 的协作图
Collaboration graph

公共成员函数

 ~GradientBooster () override=default
 虚析构函数 更多...
 
virtual void Configure (Args const &cfg)=0
 设置梯度提升的配置。用户必须在 InitModel 和 Training 之前调用一次 configure。 更多...
 
virtual void Load (dmlc::Stream *fi)=0
 从流加载模型 更多...
 
virtual void Save (dmlc::Stream *fo) const =0
 将模型保存到流。 更多...
 
virtual void Slice (bst_layer_t, bst_layer_t, bst_layer_t, GradientBooster *, bool *) const
 使用提升索引对模型进行切片。切片 m:n 表示获取在提升轮次 m, (m+1), (m+2), ..., (n-1) 期间拟合的所有树。 更多...
 
virtual std::int32_t BoostedRounds () const =0
 返回提升轮次的数量。 更多...
 
virtual bool ModelFitted () const =0
 模型是否已经训练。当选择树助推器时,如果存在树,则返回 true。 更多...
 
virtual void DoBoost (DMatrix *p_fmat, linalg::Matrix< GradientPair > *in_gpair, PredictionCacheEntry *, ObjFunction const *obj)=0
 对模型执行更新(提升) 更多...
 
virtual void PredictBatch (DMatrix *dmat, PredictionCacheEntry *out_preds, bool training, bst_layer_t begin, bst_layer_t end)=0
 为给定的特征矩阵生成预测。 更多...
 
virtual void InplacePredict (std::shared_ptr< DMatrix >, float, PredictionCacheEntry *, bst_layer_t, bst_layer_t) const
 原地预测。 更多...
 
virtual void PredictLeaf (DMatrix *dmat, HostDeviceVector< bst_float > *out_preds, unsigned layer_begin, unsigned layer_end)=0
 预测每棵树的叶子索引,输出将是一个 nsample * ntree 向量,这仅在 gbtree 预测器中有效 更多...
 
virtual void PredictContribution (DMatrix *dmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, bool approximate=false)=0
 特征对个体预测的贡献;输出将是一个长度为 (nfeats + 1) * num_output_group * nsample 的向量,并按该顺序排列 更多...
 
virtual void PredictInteractionContributions (DMatrix *dmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, bool approximate)=0
 
virtual std::vector< std::string > DumpModel (const FeatureMap &fmap, bool with_stats, std::string format) const =0
 以请求的格式导出模型 更多...
 
virtual void FeatureScore (std::string const &importance_type, common::Span< int32_t const > trees, std::vector< bst_feature_t > *features, std::vector< float > *scores) const =0
 
virtual bool UseGPU () const =0
 当前助推器是否使用 GPU。 更多...
 
- 从 xgboost::Model 继承的公共成员函数
virtual ~Model ()=default
 
virtual void LoadModel (Json const &in)=0
 从 JSON 对象加载模型 更多...
 
virtual void SaveModel (Json *out) const =0
 将模型配置保存到 JSON 对象 更多...
 
- 从 xgboost::Configurable 继承的公共成员函数
virtual ~Configurable ()=default
 
virtual void LoadConfig (Json const &in)=0
 从 JSON 对象加载配置。 更多...
 
virtual void SaveConfig (Json *out) const =0
 将配置保存到 JSON 对象。 更多...
 

静态公共成员函数

static GradientBoosterCreate (const std::string &name, Context const *ctx, LearnerModelParam const *learner_model_param)
 从给定的名称创建一个梯度助推器 更多...
 

保护成员函数

 GradientBooster (Context const *ctx)
 

保护属性

Context const * ctx_
 

详细描述

梯度提升模型的接口。

构造函数与析构函数文档

◆ GradientBooster()

xgboost::GradientBooster::GradientBooster ( Context const *  ctx)
inlineexplicit保护

◆ ~GradientBooster()

xgboost::GradientBooster::~GradientBooster ( )
overridedefault

虚析构函数

成员函数文档

◆ BoostedRounds()

virtual std::int32_t xgboost::GradientBooster::BoostedRounds ( ) const
纯虚函数

返回提升轮次的数量。

◆ Configure()

virtual void xgboost::GradientBooster::Configure ( Args const &  cfg)
纯虚函数

设置梯度提升的配置。用户必须在 InitModel 和 Training 之前调用一次 configure。

参数
cfg关于训练和模型参数的配置。

◆ Create()

static GradientBooster* xgboost::GradientBooster::Create ( const std::string &  name,
Context const *  ctx,
LearnerModelParam const *  learner_model_param 
)
静态

从给定的名称创建一个梯度助推器

参数
name梯度助推器的名称
generic_param指向运行时参数的指针
learner_model_param指向全局模型参数的指针
返回值
创建的助推器。

◆ DoBoost()

virtual void xgboost::GradientBooster::DoBoost ( DMatrix p_fmat,
linalg::Matrix< GradientPair > *  in_gpair,
PredictionCacheEntry ,
ObjFunction const *  obj 
)
纯虚函数

对模型执行更新(提升)

参数
p_fmat提供特征访问的特征矩阵
in_gpair数据的梯度对统计信息的地址
预测需要更新的输出预测缓存条目。助推器可能会改变 gpair 的内容
obj用于提升的目标函数。

◆ DumpModel()

virtual std::vector<std::string> xgboost::GradientBooster::DumpModel ( const FeatureMap fmap,
bool  with_stats,
std::string  format 
) const
纯虚函数

以请求的格式导出模型

参数
fmap可能有助于解释特征的特征映射
with_stats导出模型时的额外统计信息
格式导出模型的格式
返回值
助推器导出信息向量。

◆ FeatureScore()

virtual void xgboost::GradientBooster::FeatureScore ( std::string const &  importance_type,
common::Span< int32_t const >  trees,
std::vector< bst_feature_t > *  features,
std::vector< float > *  scores 
) const
纯虚函数

◆ InplacePredict()

virtual void xgboost::GradientBooster::InplacePredict ( std::shared_ptr< DMatrix ,
float  ,
PredictionCacheEntry ,
bst_layer_t  ,
bst_layer_t   
) const
inline虚函数

原地预测。

参数
p_fmat一个代理 DMatrix,包含数据及相关信息。
缺失值数据中的缺失值。
[输入, 输出]out_preds输出预测结果。
开始(可选)用于预测的提升树层开始。
结束(可选)助推器层结束。0 表示不限制树的数量。

◆ Load()

virtual void xgboost::GradientBooster::Load ( dmlc::Stream *  fi)
纯虚函数

从流加载模型

参数
fi输入流。

◆ ModelFitted()

virtual bool xgboost::GradientBooster::ModelFitted ( ) const
纯虚函数

模型是否已经训练。当选择树助推器时,如果存在树,则返回 true。

◆ PredictBatch()

virtual void xgboost::GradientBooster::PredictBatch ( DMatrix dmat,
PredictionCacheEntry out_preds,
bool  训练,
bst_layer_t  开始,
bst_layer_t  end 
)
纯虚函数

为给定的特征矩阵生成预测。

参数
dmat特征矩阵。
out_preds用于存放预测结果的输出向量
训练预测值是否用于训练。对于 dart 助推器,训练期间会执行 dropout。
开始用于预测的提升树层开始。
结束助推器层结束。0 表示不限制树的数量。

◆ PredictContribution()

virtual void xgboost::GradientBooster::PredictContribution ( DMatrix dmat,
HostDeviceVector< float > *  out_contribs,
bst_layer_t  layer_begin,
bst_layer_t  layer_end,
bool  approximate = false 
)
纯虚函数

特征对个体预测的贡献;输出将是一个长度为 (nfeats + 1) * num_output_group * nsample 的向量,并按该顺序排列

参数
dmat特征矩阵
out_contribs用于存放贡献值的输出向量
layer_begin用于预测的提升树层开始。
layer_end助推器层结束。0 表示不限制树的数量。
近似使用更快(不一致)的 SHAP 值近似计算

◆ PredictInteractionContributions()

virtual void xgboost::GradientBooster::PredictInteractionContributions ( DMatrix dmat,
HostDeviceVector< float > *  out_contribs,
bst_layer_t  layer_begin,
bst_layer_t  layer_end,
bool  approximate 
)
纯虚函数

◆ PredictLeaf()

virtual void xgboost::GradientBooster::PredictLeaf ( DMatrix dmat,
HostDeviceVector< bst_float > *  out_preds,
unsigned  layer_begin,
unsigned  layer_end 
)
纯虚函数

预测每棵树的叶子索引,输出将是一个 nsample * ntree 向量,这仅在 gbtree 预测器中有效

参数
dmat特征矩阵
out_preds用于存放预测结果的输出向量
layer_begin用于预测的提升树层开始。
layer_end助推器层结束。0 表示不限制树的数量。

◆ Save()

virtual void xgboost::GradientBooster::Save ( dmlc::Stream *  fo) const
纯虚函数

将模型保存到流。

参数
fo输出流

◆ Slice()

virtual void xgboost::GradientBooster::Slice ( bst_layer_t  ,
bst_layer_t  ,
bst_layer_t  ,
GradientBooster ,
bool *   
) const
inline虚函数

使用提升索引对模型进行切片。切片 m:n 表示获取在提升轮次 m, (m+1), (m+2), ..., (n-1) 期间拟合的所有树。

参数
开始用于预测的提升树层开始。
结束助推器层结束。0 表示不限制树的数量。
输出输出梯度助推器

◆ UseGPU()

virtual bool xgboost::GradientBooster::UseGPU ( ) const
纯虚函数

当前助推器是否使用 GPU。

成员数据文档

◆ ctx_

Context const* xgboost::GradientBooster::ctx_
保护

本类的文档生成自以下文件