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>
14 #include <xgboost/tree_model.h>
17 #include <xgboost/model.h>
18 
19 #include <functional>
20 #include <vector>
21 #include <utility>
22 #include <string>
23 
24 namespace xgboost {
25 
26 class Json;
27 
31 class TreeUpdater : public Configurable {
32  protected:
34 
35  public:
37  ~TreeUpdater() override = default;
42  virtual void Configure(const Args& args) = 0;
49  virtual bool CanModifyTree() const { return false; }
59  virtual void Update(HostDeviceVector<GradientPair>* gpair,
60  DMatrix* data,
61  const std::vector<RegTree*>& trees) = 0;
62 
73  virtual bool UpdatePredictionCache(const DMatrix* data,
74  HostDeviceVector<bst_float>* out_preds) {
75  return false;
76  }
77 
78  virtual char const* Name() const = 0;
79 
85  static TreeUpdater* Create(const std::string& name, GenericParameter const* tparam);
86 };
87 
92  : public dmlc::FunctionRegEntryBase<TreeUpdaterReg,
93  std::function<TreeUpdater* ()> > {
94 };
95 
108 #define XGBOOST_REGISTER_TREE_UPDATER(UniqueId, Name) \
109  static DMLC_ATTRIBUTE_UNUSED ::xgboost::TreeUpdaterReg& \
110  __make_ ## TreeUpdaterReg ## _ ## UniqueId ## __ = \
111  ::dmlc::Registry< ::xgboost::TreeUpdaterReg>::Get()->__REGISTER__(Name)
112 
113 } // namespace xgboost
114 #endif // XGBOOST_TREE_UPDATER_H_
Definition: host_device_vector.h:86
Registry entry for tree updater.
Definition: tree_updater.h:91
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:253
The input data structure of xgboost.
Definition: generic_parameters.h:14
Defines the abstract interface for different components in XGBoost.
Internal data structured used by XGBoost during training.
Definition: data.h:464
A device-and-host vector abstraction layer.
virtual bool UpdatePredictionCache(const DMatrix *data, HostDeviceVector< bst_float > *out_preds)
determines whether updater has enough knowledge about a given dataset to quickly update prediction ca...
Definition: tree_updater.h:73
virtual void Configure(const Args &args)=0
Initialize the updater with given arguments.
static TreeUpdater * Create(const std::string &name, GenericParameter const *tparam)
Create a tree updater given name.
virtual void Update(HostDeviceVector< GradientPair > *gpair, DMatrix *data, const std::vector< RegTree *> &trees)=0
perform update to the tree models
Definition: model.h:31
interface of tree update module, that performs update of a tree.
Definition: tree_updater.h:31
namespace of xgboost
Definition: base.h:102
defines configuration macros of xgboost.
virtual char const * Name() const =0
GenericParameter const * tparam_
Definition: tree_updater.h:33
~TreeUpdater() override=default
virtual destructor
virtual bool CanModifyTree() const
Whether this updater can be used for updating existing trees.
Definition: tree_updater.h:49
model structure for tree