xgboost
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
xgboost::TreeUpdater Class Referenceabstract

interface of tree update module, that performs update of a tree. More...

#include <tree_updater.h>

Inheritance diagram for xgboost::TreeUpdater:
Inheritance graph
Collaboration diagram for xgboost::TreeUpdater:
Collaboration graph

Public Member Functions

 TreeUpdater (const Context *ctx)
 
 ~TreeUpdater () override=default
 
virtual void Configure (const Args &args)=0
 Initialize the updater with given arguments. More...
 
virtual bool CanModifyTree () const
 Whether this updater can be used for updating existing trees. More...
 
virtual void Update (tree::TrainParam const *param, GradientContainer *gpair, DMatrix *p_fmat, common::Span< HostDeviceVector< bst_node_t >> out_position, std::vector< RegTree * > const &out_trees)=0
 perform update to the tree models More...
 
virtual char const * Name () const =0
 
- Public Member Functions inherited from xgboost::Configurable
virtual ~Configurable ()=default
 
virtual void LoadConfig (Json const &in)=0
 Load configuration from JSON object. More...
 
virtual void SaveConfig (Json *out) const =0
 Save configuration to JSON object. More...
 

Static Public Member Functions

static TreeUpdaterCreate (const std::string &name, Context const *ctx, ObjInfo const *task)
 Create a tree updater given name. More...
 

Protected Attributes

Context const * ctx_ = nullptr
 

Detailed Description

interface of tree update module, that performs update of a tree.

Constructor & Destructor Documentation

◆ TreeUpdater()

xgboost::TreeUpdater::TreeUpdater ( const Context ctx)
inlineexplicit

◆ ~TreeUpdater()

xgboost::TreeUpdater::~TreeUpdater ( )
overridedefault

Member Function Documentation

◆ CanModifyTree()

virtual bool xgboost::TreeUpdater::CanModifyTree ( ) const
inlinevirtual

Whether this updater can be used for updating existing trees.

Some updaters are used for building new trees (like hist), while some others are used for modifying existing trees (like prune). Return true if it can modify existing trees.

◆ Configure()

virtual void xgboost::TreeUpdater::Configure ( const Args args)
pure virtual

Initialize the updater with given arguments.

Parameters
argsarguments to the objective function.

◆ Create()

static TreeUpdater* xgboost::TreeUpdater::Create ( const std::string &  name,
Context const *  ctx,
ObjInfo const *  task 
)
static

Create a tree updater given name.

Parameters
nameName of the tree updater.
ctxA global runtime parameter
taskInfomation about the objective.

◆ Name()

virtual char const* xgboost::TreeUpdater::Name ( ) const
pure virtual

◆ Update()

virtual void xgboost::TreeUpdater::Update ( tree::TrainParam const *  param,
GradientContainer gpair,
DMatrix p_fmat,
common::Span< HostDeviceVector< bst_node_t >>  out_position,
std::vector< RegTree * > const &  out_trees 
)
pure virtual

perform update to the tree models

Parameters
paramHyper-parameter for constructing trees.
gpairThe gradient pair statistics of the data
p_fmatThe data matrix passed to the updater.
out_positionThe leaf index for each row. The index is negated if that row is removed during sampling. So the 3th node is ~3.
out_treesreferences the trees to be updated, updater will change the content of trees
Note
All the trees in the vector are updated, with the same statistics, but maybe different random seeds, usually one tree is passed in at a time, there can be multiple trees when we train a random forest style model.

Member Data Documentation

◆ ctx_

Context const* xgboost::TreeUpdater::ctx_ = nullptr
protected

The documentation for this class was generated from the following file: