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 <functional>
13 #include <vector>
14 #include <utility>
15 #include <string>
16 #include "./base.h"
17 #include "./data.h"
18 #include "./tree_model.h"
19 #include "../../src/common/host_device_vector.h"
20 
21 namespace xgboost {
25 class TreeUpdater {
26  public:
28  virtual ~TreeUpdater() = default;
33  virtual void Init(const std::vector<std::pair<std::string, std::string> >& args) = 0;
43  virtual void Update(HostDeviceVector<GradientPair>* gpair,
44  DMatrix* data,
45  const std::vector<RegTree*>& trees) = 0;
46 
57  virtual bool UpdatePredictionCache(const DMatrix* data,
58  HostDeviceVector<bst_float>* out_preds) {
59  return false;
60  }
61 
66  static TreeUpdater* Create(const std::string& name);
67 };
68 
73  : public dmlc::FunctionRegEntryBase<TreeUpdaterReg,
74  std::function<TreeUpdater* ()> > {
75 };
76 
89 #define XGBOOST_REGISTER_TREE_UPDATER(UniqueId, Name) \
90  static DMLC_ATTRIBUTE_UNUSED ::xgboost::TreeUpdaterReg& \
91  __make_ ## TreeUpdaterReg ## _ ## UniqueId ## __ = \
92  ::dmlc::Registry< ::xgboost::TreeUpdaterReg>::Get()->__REGISTER__(Name)
93 
94 } // namespace xgboost
95 #endif // XGBOOST_TREE_UPDATER_H_
Definition: host_device_vector.h:200
Registry entry for tree updater.
Definition: tree_updater.h:72
The input data structure of xgboost.
Internal data structured used by XGBoost during training. There are two ways to create a customized D...
Definition: data.h:406
virtual void Init(const std::vector< std::pair< std::string, std::string > > &args)=0
Initialize the updater with given arguments.
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:57
virtual void Update(HostDeviceVector< GradientPair > *gpair, DMatrix *data, const std::vector< RegTree *> &trees)=0
perform update to the tree models
interface of tree update module, that performs update of a tree.
Definition: tree_updater.h:25
virtual ~TreeUpdater()=default
virtual destructor
namespace of xgboost
Definition: base.h:79
defines configuration macros of xgboost.
static TreeUpdater * Create(const std::string &name)
Create a tree updater given name.
model structure for tree