21#include <unordered_map>
31struct LearnerModelParam;
32struct PredictionCacheEntry;
51 virtual void Configure(
const std::vector<std::pair<std::string, std::string> >& cfg) = 0;
71 LOG(FATAL) <<
"Slice is not supported by the current booster.";
115 LOG(FATAL) <<
"Inplace predict is not supported by the current booster.";
130 std::vector<bst_float>* out_preds,
131 unsigned layer_begin,
unsigned layer_end) = 0;
142 unsigned layer_begin,
unsigned layer_end) = 0;
155 bool approximate =
false) = 0;
159 bool approximate) = 0;
170 std::string format)
const = 0;
172 virtual void FeatureScore(std::string
const& importance_type,
174 std::vector<bst_feature_t>* features,
175 std::vector<float>* scores)
const = 0;
197 std::function<GradientBooster*(LearnerModelParam const* learner_model_param,
198 Context const* ctx)> > {};
212#define XGBOOST_REGISTER_GBM(UniqueId, Name) \
213 static DMLC_ATTRIBUTE_UNUSED ::xgboost::GradientBoosterReg & \
214 __make_ ## GradientBoosterReg ## _ ## UniqueId ## __ = \
215 ::dmlc::Registry< ::xgboost::GradientBoosterReg>::Get()->__REGISTER__(Name)
Common base class for function registry.
Definition registry.h:151
interface of stream I/O for serialization
Definition io.h:30
Internal data structured used by XGBoost during training.
Definition data.h:509
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:37
virtual void DoBoost(DMatrix *p_fmat, HostDeviceVector< GradientPair > *in_gpair, PredictionCacheEntry *, ObjFunction const *obj)=0
perform update to the model(boosting)
virtual void Load(dmlc::Stream *fi)=0
load model from stream
~GradientBooster() override=default
virtual destructor
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 void InplacePredict(std::shared_ptr< DMatrix >, float, PredictionCacheEntry *, bst_layer_t, bst_layer_t) const
Inplace prediction.
Definition gbm.h:113
virtual bool UseGPU() const =0
Whether the current booster uses GPU.
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.
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 void PredictContribution(DMatrix *dmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, bool approximate=false)=0
feature contributions to individual predictions; the output will be a vector of length (nfeats + 1) *...
virtual std::vector< std::string > DumpModel(const FeatureMap &fmap, bool with_stats, std::string format) const =0
dump the model in the requested format
static GradientBooster * Create(const std::string &name, Context const *ctx, LearnerModelParam const *learner_model_param)
create a gradient booster from given name
Definition gbm.cc:22
virtual int32_t BoostedRounds() const =0
Return number of boosted rounds.
virtual void PredictBatch(DMatrix *dmat, PredictionCacheEntry *out_preds, bool training, bst_layer_t begin, bst_layer_t end)=0
Generate predictions for given feature matrix.
virtual void Slice(bst_layer_t, bst_layer_t, bst_layer_t, GradientBooster *, bool *) const
Slice a model using boosting index.
Definition gbm.h:69
Definition host_device_vector.h:87
interface of objective function
Definition objective.h:29
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition span.h:424
A device-and-host vector abstraction layer.
Copyright 2015-2023 by XGBoost Contributors.
Copyright 2015-2023 by XGBoost Contributors.
Defines the abstract interface for different components in XGBoost.
namespace of xgboost
Definition base.h:90
std::int32_t bst_layer_t
Type for indexing boosted layers.
Definition base.h:122
Registry utility that helps to build registry singletons.
Runtime context for XGBoost.
Definition context.h:84
Registry entry for tree updater.
Definition gbm.h:198
Basic model parameters, used to describe the booster.
Definition learner.h:291
Contains pointer to input matrix and associated cached predictions.
Definition predictor.h:30