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 #include <xgboost/linalg.h>
19 
20 #include <functional>
21 #include <vector>
22 #include <utility>
23 #include <string>
24 
25 namespace xgboost {
26 
27 class Json;
28 
32 class TreeUpdater : public Configurable {
33  protected:
35 
36  public:
38  ~TreeUpdater() override = default;
43  virtual void Configure(const Args& args) = 0;
50  virtual bool CanModifyTree() const { return false; }
60  virtual void Update(HostDeviceVector<GradientPair>* gpair,
61  DMatrix* data,
62  const std::vector<RegTree*>& trees) = 0;
63 
74  virtual bool UpdatePredictionCache(const DMatrix * /*data*/,
75  VectorView<float> /*out_preds*/) {
76  return false;
77  }
78 
79  virtual char const* Name() const = 0;
80 
86  static TreeUpdater* Create(const std::string& name, GenericParameter const* tparam);
87 };
88 
93  : public dmlc::FunctionRegEntryBase<TreeUpdaterReg,
94  std::function<TreeUpdater* ()> > {
95 };
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::TreeUpdater::tparam_
GenericParameter const * tparam_
Definition: tree_updater.h:34
xgboost::Args
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:265
xgboost::TreeUpdater::UpdatePredictionCache
virtual bool UpdatePredictionCache(const DMatrix *, VectorView< float >)
determines whether updater has enough knowledge about a given dataset to quickly update prediction ca...
Definition: tree_updater.h:74
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:50
xgboost::TreeUpdater::Update
virtual void Update(HostDeviceVector< GradientPair > *gpair, DMatrix *data, const std::vector< RegTree * > &trees)=0
perform update to the tree models
xgboost::GenericParameter
Definition: generic_parameters.h:15
xgboost::TreeUpdater
interface of tree update module, that performs update of a tree.
Definition: tree_updater.h:32
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:92
base.h
defines configuration macros of xgboost.
xgboost::DMatrix
Internal data structured used by XGBoost during training.
Definition: data.h:469
xgboost::TreeUpdater::Name
virtual char const * Name() const =0
xgboost::TreeUpdater::~TreeUpdater
~TreeUpdater() override=default
virtual destructor
linalg.h
Linear algebra related utilities.
xgboost::TreeUpdater::Create
static TreeUpdater * Create(const std::string &name, GenericParameter const *tparam)
Create a tree updater given name.
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::VectorView
A slice for 1 column of MatrixView. Can be extended to row if needed.
Definition: linalg.h:93
xgboost::TreeUpdater::Configure
virtual void Configure(const Args &args)=0
Initialize the updater with given arguments.
xgboost
namespace of xgboost
Definition: base.h:110