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>
15 #include <xgboost/generic_parameters.h>
16 #include <xgboost/host_device_vector.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:
33 GenericParameter const* tparam_;
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
91 struct TreeUpdaterReg
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_
xgboost::HostDeviceVector
Definition: host_device_vector.h:85
xgboost::TreeUpdaterReg
Registry entry for tree updater.
Definition: tree_updater.h:91
xgboost::Args
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:245
data.h
The input data structure of xgboost.
xgboost::GenericParameter
Definition: generic_parameters.h:14
model.h
Defines the abstract interface for different components in XGBoost.
xgboost::DMatrix
Internal data structured used by XGBoost during training. There are two ways to create a customized D...
Definition: data.h:451
host_device_vector.h
A device-and-host vector abstraction layer.
xgboost::TreeUpdater::UpdatePredictionCache
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
xgboost::TreeUpdater::Configure
virtual void Configure(const Args &args)=0
Initialize the updater with given arguments.
xgboost::TreeUpdater::Create
static TreeUpdater * Create(const std::string &name, GenericParameter const *tparam)
Create a tree updater given name.
xgboost::TreeUpdater::Update
virtual void Update(HostDeviceVector< GradientPair > *gpair, DMatrix *data, const std::vector< RegTree *> &trees)=0
perform update to the tree models
xgboost::Configurable
Definition: model.h:31
xgboost::TreeUpdater
interface of tree update module, that performs update of a tree.
Definition: tree_updater.h:31
xgboost
namespace of xgboost
Definition: base.h:102
base.h
defines configuration macros of xgboost.
xgboost::TreeUpdater::Name
virtual char const * Name() const =0
xgboost::TreeUpdater::tparam_
GenericParameter const * tparam_
Definition: tree_updater.h:33
xgboost::TreeUpdater::~TreeUpdater
~TreeUpdater() override=default
virtual destructor
generic_parameters.h
xgboost::TreeUpdater::CanModifyTree
virtual bool CanModifyTree() const
Whether this updater can be used for updating existing trees.
Definition: tree_updater.h:49
tree_model.h
model structure for tree