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  virtual ~TreeUpdater() = default;
42  virtual void Configure(const Args& args) = 0;
52  virtual void Update(HostDeviceVector<GradientPair>* gpair,
53  DMatrix* data,
54  const std::vector<RegTree*>& trees) = 0;
55 
66  virtual bool UpdatePredictionCache(const DMatrix* data,
67  HostDeviceVector<bst_float>* out_preds) {
68  return false;
69  }
70 
71  virtual char const* Name() const = 0;
72 
77  static TreeUpdater* Create(const std::string& name, GenericParameter const* tparam);
78 };
79 
84  : public dmlc::FunctionRegEntryBase<TreeUpdaterReg,
85  std::function<TreeUpdater* ()> > {
86 };
87 
100 #define XGBOOST_REGISTER_TREE_UPDATER(UniqueId, Name) \
101  static DMLC_ATTRIBUTE_UNUSED ::xgboost::TreeUpdaterReg& \
102  __make_ ## TreeUpdaterReg ## _ ## UniqueId ## __ = \
103  ::dmlc::Registry< ::xgboost::TreeUpdaterReg>::Get()->__REGISTER__(Name)
104 
105 } // namespace xgboost
106 #endif // XGBOOST_TREE_UPDATER_H_
Definition: host_device_vector.h:85
Registry entry for tree updater.
Definition: tree_updater.h:83
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:238
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. There are two ways to create a customized D...
Definition: data.h:428
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:66
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
virtual ~TreeUpdater()=default
virtual destructor
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
model structure for tree