11 #include <dmlc/registry.h>
22 #include <unordered_map>
31 struct GenericParameter;
32 struct LearnerModelParam;
33 struct PredictionCacheEntry;
34 class PredictionContainer;
53 virtual void Configure(
const std::vector<std::pair<std::string, std::string> >& cfg) = 0;
58 virtual void Load(dmlc::Stream* fi) = 0;
63 virtual void Save(dmlc::Stream* fo)
const = 0;
71 virtual void Slice(int32_t , int32_t , int32_t ,
73 LOG(FATAL) <<
"Slice is not supported by current booster.";
105 unsigned layer_begin,
106 unsigned layer_end) = 0;
120 LOG(FATAL) <<
"Inplace predict is not supported by current booster.";
135 std::vector<bst_float>* out_preds,
136 unsigned layer_begin,
unsigned layer_end) = 0;
147 unsigned layer_begin,
unsigned layer_end) = 0;
162 unsigned layer_begin,
unsigned layer_end,
163 bool approximate =
false,
int condition = 0,
164 unsigned condition_feature = 0) = 0;
168 unsigned layer_begin,
unsigned layer_end,
bool approximate) = 0;
179 std::string format)
const = 0;
183 std::vector<bst_feature_t>* features,
184 std::vector<float>* scores)
const = 0;
197 const std::string& name,
206 :
public dmlc::FunctionRegEntryBase<
208 std::function<GradientBooster*(LearnerModelParam const* learner_model_param,
209 GenericParameter const* ctx)> > {};
223 #define XGBOOST_REGISTER_GBM(UniqueId, Name) \
224 static DMLC_ATTRIBUTE_UNUSED ::xgboost::GradientBoosterReg & \
225 __make_ ## GradientBoosterReg ## _ ## UniqueId ## __ = \
226 ::dmlc::Registry< ::xgboost::GradientBoosterReg>::Get()->__REGISTER__(Name)
defines configuration macros of xgboost.
Internal data structured used by XGBoost during training.
Definition: data.h:490
Feature map data structure to help text model dump. TODO(tqchen) consider make it even more lightweig...
Definition: feature_map.h:22
interface of gradient boosting model.
Definition: gbm.h:39
virtual void DoBoost(DMatrix *p_fmat, HostDeviceVector< GradientPair > *in_gpair, PredictionCacheEntry *, ObjFunction const *obj)=0
perform update to the model(boosting)
static GradientBooster * Create(const std::string &name, GenericParameter const *generic_param, LearnerModelParam const *learner_model_param)
create a gradient booster from given name
virtual void Load(dmlc::Stream *fi)=0
load model from stream
~GradientBooster() override=default
virtual destructor
GradientBooster(GenericParameter const *ctx)
Definition: gbm.h:42
virtual void PredictContribution(DMatrix *dmat, HostDeviceVector< bst_float > *out_contribs, unsigned layer_begin, unsigned layer_end, bool approximate=false, int condition=0, unsigned condition_feature=0)=0
feature contributions to individual predictions; the output will be a vector of length (nfeats + 1) *...
virtual void PredictLeaf(DMatrix *dmat, HostDeviceVector< bst_float > *out_preds, unsigned layer_begin, unsigned layer_end)=0
predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in ...
virtual std::vector< std::string > DumpModel(const FeatureMap &fmap, bool with_stats, std::string format) const =0
dump the model in the requested format
virtual void InplacePredict(std::shared_ptr< DMatrix >, float, PredictionCacheEntry *, uint32_t, uint32_t) const
Inplace prediction.
Definition: gbm.h:118
virtual void FeatureScore(std::string const &importance_type, common::Span< int32_t const > trees, std::vector< bst_feature_t > *features, std::vector< float > *scores) const =0
virtual bool UseGPU() const =0
Whether the current booster uses GPU.
virtual void PredictBatch(DMatrix *dmat, PredictionCacheEntry *out_preds, bool training, unsigned layer_begin, unsigned layer_end)=0
generate predictions for given feature matrix
virtual void Configure(const std::vector< std::pair< std::string, std::string > > &cfg)=0
Set the configuration of gradient boosting. User must call configure once before InitModel and Traini...
virtual bool ModelFitted() const =0
Whether the model has already been trained. When tree booster is chosen, then returns true when there...
virtual void Save(dmlc::Stream *fo) const =0
save model to stream.
virtual void PredictInstance(const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, unsigned layer_begin, unsigned layer_end)=0
online prediction function, predict score for one instance at a time NOTE: use the batch prediction i...
virtual int32_t BoostedRounds() const =0
Return number of boosted rounds.
GenericParameter const * ctx_
Definition: gbm.h:41
virtual void PredictInteractionContributions(DMatrix *dmat, HostDeviceVector< bst_float > *out_contribs, unsigned layer_begin, unsigned layer_end, bool approximate)=0
virtual void Slice(int32_t, int32_t, int32_t, GradientBooster *, bool *) const
Slice a model using boosting index. The slice m:n indicates taking all trees that were fit during the...
Definition: gbm.h:71
Definition: host_device_vector.h:86
interface of objective function
Definition: objective.h:28
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition: span.h:423
The input data structure of xgboost.
A device-and-host vector abstraction layer.
Defines the abstract interface for different components in XGBoost.
namespace of xgboost
Definition: base.h:110
Definition: generic_parameters.h:15
Registry entry for tree updater.
Definition: gbm.h:209
Definition: learner.h:299
Contains pointer to input matrix and associated cached predictions.
Definition: predictor.h:35