11 #include <dmlc/registry.h>
31 struct LearnerModelParam;
32 struct PredictionCacheEntry;
62 LOG(FATAL) <<
"Slice is not supported by the current booster.";
109 LOG(FATAL) <<
"Inplace predict is not supported by the current booster.";
121 unsigned layer_begin,
unsigned layer_end) = 0;
134 bool approximate =
false) = 0;
138 bool approximate) = 0;
148 std::string format)
const = 0;
152 std::vector<bst_feature_t>* features,
153 std::vector<float>* scores)
const = 0;
157 [[nodiscard]]
virtual CatContainer
const*
Cats()
const {
158 LOG(FATAL) <<
"Retrieving categories is not supported by the current booster.";
176 :
public dmlc::FunctionRegEntryBase<
178 std::function<GradientBooster*(LearnerModelParam const* learner_model_param,
179 Context const* ctx)> > {};
193 #define XGBOOST_REGISTER_GBM(UniqueId, Name) \
194 static DMLC_ATTRIBUTE_UNUSED ::xgboost::GradientBoosterReg & \
195 __make_ ## GradientBoosterReg ## _ ## UniqueId ## __ = \
196 ::dmlc::Registry< ::xgboost::GradientBoosterReg>::Get()->__REGISTER__(Name)
Defines configuration macros and basic types for xgboost.
Internal data structured used by XGBoost to hold all external data.
Definition: data.h:577
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
~GradientBooster() override=default
virtual destructor
GradientBooster(Context const *ctx)
Definition: gbm.h:40
virtual std::int32_t BoostedRounds() const =0
Return number of boosted rounds.
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 PredictInteractionContributions(DMatrix *dmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, bool approximate)=0
virtual void Configure(Args const &cfg)=0
Set the configuration of gradient boosting. User must call configure once before InitModel and Traini...
virtual void InplacePredict(std::shared_ptr< DMatrix >, float, PredictionCacheEntry *, bst_layer_t, bst_layer_t) const
Inplace prediction.
Definition: gbm.h:107
static GradientBooster * Create(const std::string &name, Context const *ctx, LearnerModelParam const *learner_model_param)
create a gradient booster from given name
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 ModelFitted() const =0
Whether the model has already been trained. When tree booster is chosen, then returns true when there...
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) *...
Context const * ctx_
Definition: gbm.h:39
virtual void DoBoost(DMatrix *p_fmat, GradientContainer *in_gpair, PredictionCacheEntry *prediction, ObjFunction const *obj)=0
perform update to the model(boosting)
virtual CatContainer const * Cats() const
Getter for categories.
Definition: gbm.h:157
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. The slice m:n indicates taking all trees that were fit during the...
Definition: gbm.h:60
The 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:435
The input data structure of xgboost.
A device-and-host vector abstraction layer.
Defines the abstract interface for different components in XGBoost.
Learner interface that integrates objective, gbm and evaluation together. This is the user facing XGB...
Definition: base.h:89
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:306
std::int32_t bst_layer_t
Type for indexing boosted layers.
Definition: base.h:123
Runtime context for XGBoost. Contains information like threads and device.
Definition: context.h:142
Registry entry for tree updater.
Definition: gbm.h:179
Container for gradient produced by objective.
Definition: gradient.h:16
Basic model parameters, used to describe the booster.
Definition: learner.h:297
Contains pointer to input matrix and associated cached predictions.
Definition: predictor.h:30