xgboost
tree_updater.h
Go to the documentation of this file.
1 
8 #ifndef XGBOOST_TREE_UPDATER_H_
9 #define XGBOOST_TREE_UPDATER_H_
10 
11 #include <dmlc/registry.h>
12 #include <xgboost/base.h>
13 #include <xgboost/data.h>
16 #include <xgboost/linalg.h>
17 #include <xgboost/model.h>
18 #include <xgboost/task.h>
19 #include <xgboost/tree_model.h>
20 
21 #include <functional>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 
26 namespace xgboost {
27 
28 class Json;
29 
33 class TreeUpdater : public Configurable {
34  protected:
35  GenericParameter const* ctx_ = nullptr;
36 
37  public:
39  ~TreeUpdater() override = default;
44  virtual void Configure(const Args& args) = 0;
51  virtual bool CanModifyTree() const { return false; }
61  virtual void Update(HostDeviceVector<GradientPair>* gpair,
62  DMatrix* data,
63  const std::vector<RegTree*>& trees) = 0;
64 
75  virtual bool UpdatePredictionCache(const DMatrix * /*data*/,
76  linalg::VectorView<float> /*out_preds*/) {
77  return false;
78  }
79 
80  virtual char const* Name() const = 0;
81 
87  static TreeUpdater* Create(const std::string& name, GenericParameter const* tparam, ObjInfo task);
88 };
89 
94  : public dmlc::FunctionRegEntryBase<TreeUpdaterReg,
95  std::function<TreeUpdater*(ObjInfo task)> > {};
96 
109 #define XGBOOST_REGISTER_TREE_UPDATER(UniqueId, Name) \
110  static DMLC_ATTRIBUTE_UNUSED ::xgboost::TreeUpdaterReg& \
111  __make_ ## TreeUpdaterReg ## _ ## UniqueId ## __ = \
112  ::dmlc::Registry< ::xgboost::TreeUpdaterReg>::Get()->__REGISTER__(Name)
113 
114 } // namespace xgboost
115 #endif // XGBOOST_TREE_UPDATER_H_
xgboost::linalg::TensorView
A tensor view with static type and dimension. It implements indexing and slicing.
Definition: linalg.h:244
xgboost::Args
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:265
task.h
model.h
Defines the abstract interface for different components in XGBoost.
xgboost::TreeUpdater::CanModifyTree
virtual bool CanModifyTree() const
Whether this updater can be used for updating existing trees.
Definition: tree_updater.h:51
xgboost::TreeUpdater::Update
virtual void Update(HostDeviceVector< GradientPair > *gpair, DMatrix *data, const std::vector< RegTree * > &trees)=0
perform update to the tree models
xgboost::TreeUpdater::Create
static TreeUpdater * Create(const std::string &name, GenericParameter const *tparam, ObjInfo task)
Create a tree updater given name.
xgboost::GenericParameter
Definition: generic_parameters.h:15
xgboost::TreeUpdater
interface of tree update module, that performs update of a tree.
Definition: tree_updater.h:33
xgboost::HostDeviceVector
Definition: host_device_vector.h:86
host_device_vector.h
A device-and-host vector abstraction layer.
xgboost::TreeUpdaterReg
Registry entry for tree updater.
Definition: tree_updater.h:93
base.h
defines configuration macros of xgboost.
xgboost::TreeUpdater::UpdatePredictionCache
virtual bool UpdatePredictionCache(const DMatrix *, linalg::VectorView< float >)
determines whether updater has enough knowledge about a given dataset to quickly update prediction ca...
Definition: tree_updater.h:75
xgboost::DMatrix
Internal data structured used by XGBoost during training.
Definition: data.h:475
xgboost::TreeUpdater::Name
virtual char const * Name() const =0
xgboost::TreeUpdater::~TreeUpdater
~TreeUpdater() override=default
virtual destructor
linalg.h
Linear algebra related utilities.
xgboost::Configurable
Definition: model.h:31
generic_parameters.h
data.h
The input data structure of xgboost.
tree_model.h
model structure for tree
xgboost::TreeUpdater::ctx_
GenericParameter const * ctx_
Definition: tree_updater.h:35
xgboost::ObjInfo
A struct returned by objective, which determines task at hand. The struct is not used by any algorith...
Definition: task.h:24
xgboost::TreeUpdater::Configure
virtual void Configure(const Args &args)=0
Initialize the updater with given arguments.
xgboost
namespace of xgboost
Definition: base.h:110