Medial Code Documentation
|
Public Member Functions | |
GBTree (LearnerModelParam const *booster_config, Context const *ctx) | |
void | Configure (Args const &cfg) override |
Set the configuration of gradient boosting. User must call configure once before InitModel and Training. | |
void | UpdateTreeLeaf (DMatrix const *p_fmat, HostDeviceVector< float > const &predictions, ObjFunction const *obj, std::int32_t group_idx, std::vector< HostDeviceVector< bst_node_t > > const &node_position, std::vector< std::unique_ptr< RegTree > > *p_trees) |
Optionally update the leaf value. | |
void | DoBoost (DMatrix *p_fmat, HostDeviceVector< GradientPair > *in_gpair, PredictionCacheEntry *predt, ObjFunction const *obj) override |
Carry out one iteration of boosting. | |
bool | UseGPU () const override |
Whether the current booster uses GPU. | |
GBTreeTrainParam const & | GetTrainParam () const |
void | Load (dmlc::Stream *fi) override |
load model from stream | |
void | Save (dmlc::Stream *fo) const override |
save model to stream. | |
void | LoadConfig (Json const &in) override |
Load configuration from JSON object. | |
void | SaveConfig (Json *p_out) const override |
Save configuration to JSON object. | |
void | SaveModel (Json *p_out) const override |
saves the model config to a JSON object | |
void | LoadModel (Json const &in) override |
load the model from a JSON object | |
void | Slice (bst_layer_t begin, bst_layer_t end, bst_layer_t step, GradientBooster *out, bool *out_of_bound) const override |
Slice a model using boosting index. | |
std::int32_t | BoostedRounds () const override |
Return number of boosted rounds. | |
bool | ModelFitted () const override |
Whether the model has already been trained. | |
void | PredictBatchImpl (DMatrix *p_fmat, PredictionCacheEntry *out_preds, bool is_training, bst_layer_t layer_begin, bst_layer_t layer_end) const |
void | PredictBatch (DMatrix *p_fmat, PredictionCacheEntry *out_preds, bool training, bst_layer_t layer_begin, bst_layer_t layer_end) override |
Generate predictions for given feature matrix. | |
void | InplacePredict (std::shared_ptr< DMatrix > p_m, float missing, PredictionCacheEntry *out_preds, bst_layer_t layer_begin, bst_layer_t layer_end) const override |
Inplace prediction. | |
void | FeatureScore (std::string const &importance_type, common::Span< int32_t const > trees, std::vector< bst_feature_t > *features, std::vector< float > *scores) const override |
void | PredictInstance (const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, uint32_t layer_begin, uint32_t layer_end) override |
void | PredictLeaf (DMatrix *p_fmat, HostDeviceVector< bst_float > *out_preds, uint32_t layer_begin, uint32_t layer_end) override |
void | PredictContribution (DMatrix *p_fmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, bool approximate) override |
feature contributions to individual predictions; the output will be a vector of length (nfeats + 1) * num_output_group * nsample, arranged in that order | |
void | PredictInteractionContributions (DMatrix *p_fmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, bool approximate) override |
std::vector< std::string > | DumpModel (const FeatureMap &fmap, bool with_stats, std::string format) const override |
dump the model in the requested format | |
![]() | |
~GradientBooster () override=default | |
virtual destructor | |
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 interface if possible, batch prediction is usually more efficient than online prediction This function is NOT threadsafe, make sure you only call from one thread | |
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 gbtree predictor | |
Protected Member Functions | |
void | BoostNewTrees (HostDeviceVector< GradientPair > *gpair, DMatrix *p_fmat, int bst_group, std::vector< HostDeviceVector< bst_node_t > > *out_position, std::vector< std::unique_ptr< RegTree > > *ret) |
std::unique_ptr< Predictor > const & | GetPredictor (bool is_training, HostDeviceVector< float > const *out_pred=nullptr, DMatrix *f_dmat=nullptr) const |
virtual void | CommitModel (TreesOneIter &&new_trees) |
![]() | |
GradientBooster (Context const *ctx) | |
Protected Attributes | |
GBTreeModel | model_ |
GBTreeTrainParam | tparam_ |
tree::TrainParam | tree_param_ |
bool | specified_updater_ {false} |
std::vector< std::unique_ptr< TreeUpdater > > | updaters_ |
std::unique_ptr< Predictor > | cpu_predictor_ |
std::unique_ptr< Predictor > | gpu_predictor_ {nullptr} |
common::Monitor | monitor_ |
![]() | |
Context const * | ctx_ |
Additional Inherited Members | |
![]() | |
static GradientBooster * | Create (const std::string &name, Context const *ctx, LearnerModelParam const *learner_model_param) |
create a gradient booster from given name | |
|
inlineoverridevirtual |
Return number of boosted rounds.
Implements xgboost::GradientBooster.
|
overridevirtual |
Set the configuration of gradient boosting. User must call configure once before InitModel and Training.
cfg | configurations on both training and model parameters. |
Implements xgboost::GradientBooster.
|
overridevirtual |
Carry out one iteration of boosting.
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
dump the model in the requested format
fmap | feature map that may help give interpretations of feature |
with_stats | extra statistics while dumping model |
format | the format to dump the model in |
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
Implements xgboost::GradientBooster.
|
overridevirtual |
Inplace prediction.
p_fmat | A proxy DMatrix that contains the data and related. | |
missing | Missing value in the data. | |
[in,out] | out_preds | The output preds. |
begin | (Optional) Beginning of boosted tree layer used for prediction. | |
end | (Optional) End of booster layer. 0 means do not limit trees. |
Reimplemented from xgboost::GradientBooster.
|
inlineoverridevirtual |
|
overridevirtual |
Load configuration from JSON object.
in | JSON object containing the configuration |
Implements xgboost::Configurable.
|
overridevirtual |
load the model from a JSON object
in | JSON object where to load the model from |
Implements xgboost::Model.
|
inlineoverridevirtual |
Whether the model has already been trained.
When tree booster is chosen, then returns true when there are existing trees.
Implements xgboost::GradientBooster.
|
overridevirtual |
Generate predictions for given feature matrix.
dmat | The feature matrix. |
out_preds | output vector to hold the predictions |
training | Whether the prediction value is used for training. For dart booster drop out is performed during training. |
begin | Beginning of boosted tree layer used for prediction. |
end | End of booster layer. 0 means do not limit trees. |
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
feature contributions to individual predictions; the output will be a vector of length (nfeats + 1) * num_output_group * nsample, arranged in that order
dmat | feature matrix |
out_contribs | output vector to hold the contributions |
layer_begin | Beginning of boosted tree layer used for prediction. |
layer_end | End of booster layer. 0 means do not limit trees. |
approximate | use a faster (inconsistent) approximation of SHAP values |
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
|
overridevirtual |
Save configuration to JSON object.
out | pointer to output JSON object |
Implements xgboost::Configurable.
|
overridevirtual |
saves the model config to a JSON object
out | JSON container where to save the model to |
Implements xgboost::Model.
|
overridevirtual |
Slice a model using boosting index.
The slice m:n indicates taking all trees that were fit during the boosting rounds m, (m+1), (m+2), ..., (n-1).
begin | Beginning of boosted tree layer used for prediction. |
end | End of booster layer. 0 means do not limit trees. |
out | Output gradient booster |
Reimplemented from xgboost::GradientBooster.
|
inlineoverridevirtual |
Whether the current booster uses GPU.
Implements xgboost::GradientBooster.