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 bool UpdatePredictionCacheMulticlass(const DMatrix* /*data*/,
79 HostDeviceVector<bst_float>* /*out_preds*/,
80 const int /*gid*/, const int /*ngroup*/) {
81 return false;
82 }
83
84 virtual char const* Name() const = 0;
85
91 static TreeUpdater* Create(const std::string& name, GenericParameter const* tparam);
92 };
93
97 struct TreeUpdaterReg
98 : public dmlc::FunctionRegEntryBase<TreeUpdaterReg,
99 std::function<TreeUpdater* ()> > {
100 };
101
114 #define XGBOOST_REGISTER_TREE_UPDATER(UniqueId, Name) \
115 static DMLC_ATTRIBUTE_UNUSED ::xgboost::TreeUpdaterReg& \
116 __make_ ## TreeUpdaterReg ## _ ## UniqueId ## __ = \
117 ::dmlc::Registry< ::xgboost::TreeUpdaterReg>::Get()->__REGISTER__(Name)
118
119 } // namespace xgboost
120 #endif // XGBOOST_TREE_UPDATER_H_
xgboost::TreeUpdater::UpdatePredictionCacheMulticlass
virtual bool UpdatePredictionCacheMulticlass(const DMatrix *, HostDeviceVector< bst_float > *, const int, const int)
Definition: tree_updater.h:78
xgboost::TreeUpdater::tparam_
GenericParameter const * tparam_
Definition: tree_updater.h:33
xgboost::Args
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:262
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:49
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:31
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:97
base.h
defines configuration macros of xgboost.
xgboost::DMatrix
Internal data structured used by XGBoost during training.
Definition: data.h:449
xgboost::TreeUpdater::Name
virtual char const * Name() const =0
xgboost::TreeUpdater::~TreeUpdater
~TreeUpdater() override=default
virtual destructor
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
xgboost::TreeUpdater::UpdatePredictionCache
virtual bool UpdatePredictionCache(const DMatrix *, HostDeviceVector< bst_float > *)
determines whether updater has enough knowledge about a given dataset to quickly update prediction ca...
Definition: tree_updater.h:73
data.h
The input data structure of xgboost.
tree_model.h
model structure for tree
xgboost::TreeUpdater::Configure
virtual void Configure(const Args &args)=0
Initialize the updater with given arguments.
xgboost
namespace of xgboost
Definition: base.h:110