Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes
xgboost::gbm::Dart Class Reference
Inheritance diagram for xgboost::gbm::Dart:
xgboost::gbm::GBTree xgboost::GradientBooster xgboost::Model xgboost::Configurable

Public Member Functions

 Dart (LearnerModelParam const *booster_config, Context const *ctx)
 
void Configure (const Args &cfg) override
 Set the configuration of gradient boosting. User must call configure once before InitModel and Training.
 
void Slice (int32_t layer_begin, int32_t layer_end, int32_t step, GradientBooster *out, bool *out_of_bound) const final
 
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 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 PredictBatchImpl (DMatrix *p_fmat, PredictionCacheEntry *p_out_preds, bool training, unsigned layer_begin, unsigned layer_end) const
 
void PredictBatch (DMatrix *p_fmat, PredictionCacheEntry *p_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_fmat, float missing, PredictionCacheEntry *p_out_preds, bst_layer_t layer_begin, bst_layer_t layer_end) const override
 Inplace prediction.
 
void PredictInstance (const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, unsigned layer_begin, unsigned layer_end) override
 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
 
void PredictContribution (DMatrix *p_fmat, HostDeviceVector< bst_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
 
- Public Member Functions inherited from xgboost::gbm::GBTree
 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
 
- Public Member Functions inherited from xgboost::GradientBooster
 ~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 gbtree predictor
 

Protected Member Functions

void CommitModel (TreesOneIter &&new_trees) override
 
void DropTrees (bool is_training)
 
std::size_t NormalizeTrees (size_t size_new_trees)
 
void InitThreadTemp (int nthread)
 
- Protected Member Functions inherited from xgboost::gbm::GBTree
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
 
- Protected Member Functions inherited from xgboost::GradientBooster
 GradientBooster (Context const *ctx)
 

Protected Attributes

DartTrainParam dparam_
 
std::vector< bst_floatweight_drop_
 prediction buffer
 
std::vector< size_t > idx_drop_
 
std::vector< RegTree::FVecthread_temp_
 
- Protected Attributes inherited from xgboost::gbm::GBTree
GBTreeModel model_
 
GBTreeTrainParam tparam_
 
tree::TrainParam tree_param_
 
bool specified_updater_ {false}
 
std::vector< std::unique_ptr< TreeUpdater > > updaters_
 
std::unique_ptr< Predictorcpu_predictor_
 
std::unique_ptr< Predictorgpu_predictor_ {nullptr}
 
common::Monitor monitor_
 
- Protected Attributes inherited from xgboost::GradientBooster
Context const * ctx_
 

Additional Inherited Members

- Static Public Member Functions inherited from xgboost::GradientBooster
static GradientBoosterCreate (const std::string &name, Context const *ctx, LearnerModelParam const *learner_model_param)
 create a gradient booster from given name
 

Member Function Documentation

◆ CommitModel()

void xgboost::gbm::Dart::CommitModel ( TreesOneIter &&  new_trees)
inlineoverrideprotectedvirtual

Reimplemented from xgboost::gbm::GBTree.

◆ Configure()

void xgboost::gbm::Dart::Configure ( const Args &  cfg)
inlineoverridevirtual

Set the configuration of gradient boosting. User must call configure once before InitModel and Training.

Parameters
cfgconfigurations on both training and model parameters.

Implements xgboost::GradientBooster.

◆ InplacePredict()

void xgboost::gbm::Dart::InplacePredict ( std::shared_ptr< DMatrix ,
float  ,
PredictionCacheEntry ,
bst_layer_t  ,
bst_layer_t   
) const
inlineoverridevirtual

Inplace prediction.

Parameters
p_fmatA proxy DMatrix that contains the data and related.
missingMissing value in the data.
[in,out]out_predsThe 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.

◆ Load()

void xgboost::gbm::Dart::Load ( dmlc::Stream fi)
inlineoverridevirtual

load model from stream

Parameters
fiinput stream.

Implements xgboost::GradientBooster.

◆ LoadConfig()

void xgboost::gbm::Dart::LoadConfig ( Json const &  in)
inlineoverridevirtual

Load configuration from JSON object.

Parameters
inJSON object containing the configuration

Implements xgboost::Configurable.

◆ LoadModel()

void xgboost::gbm::Dart::LoadModel ( Json const &  in)
inlineoverridevirtual

load the model from a JSON object

Parameters
inJSON object where to load the model from

Implements xgboost::Model.

◆ PredictBatch()

void xgboost::gbm::Dart::PredictBatch ( DMatrix dmat,
PredictionCacheEntry out_preds,
bool  training,
bst_layer_t  begin,
bst_layer_t  end 
)
inlineoverridevirtual

Generate predictions for given feature matrix.

Parameters
dmatThe feature matrix.
out_predsoutput vector to hold the predictions
trainingWhether the prediction value is used for training. For dart booster drop out is performed during training.
beginBeginning of boosted tree layer used for prediction.
endEnd of booster layer. 0 means do not limit trees.

Implements xgboost::GradientBooster.

◆ PredictContribution()

void xgboost::gbm::Dart::PredictContribution ( DMatrix dmat,
HostDeviceVector< bst_float > *  out_contribs,
bst_layer_t  layer_begin,
bst_layer_t  layer_end,
bool  approximate 
)
inlineoverridevirtual

feature contributions to individual predictions; the output will be a vector of length (nfeats + 1) * num_output_group * nsample, arranged in that order

Parameters
dmatfeature matrix
out_contribsoutput vector to hold the contributions
layer_beginBeginning of boosted tree layer used for prediction.
layer_endEnd of booster layer. 0 means do not limit trees.
approximateuse a faster (inconsistent) approximation of SHAP values

Implements xgboost::GradientBooster.

◆ PredictInstance()

void xgboost::gbm::Dart::PredictInstance ( const SparsePage::Inst inst,
std::vector< bst_float > *  out_preds,
unsigned  layer_begin,
unsigned  layer_end 
)
inlineoverridevirtual

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

Parameters
instthe instance you want to predict
out_predsoutput vector to hold the predictions
layer_beginBeginning of boosted tree layer used for prediction.
layer_endEnd of booster layer. 0 means do not limit trees.
See also
Predict

Implements xgboost::GradientBooster.

◆ PredictInteractionContributions()

void xgboost::gbm::Dart::PredictInteractionContributions ( DMatrix p_fmat,
HostDeviceVector< float > *  out_contribs,
bst_layer_t  layer_begin,
bst_layer_t  layer_end,
bool  approximate 
)
inlineoverridevirtual

◆ Save()

void xgboost::gbm::Dart::Save ( dmlc::Stream fo) const
inlineoverridevirtual

save model to stream.

Parameters
fooutput stream

Implements xgboost::GradientBooster.

◆ SaveConfig()

void xgboost::gbm::Dart::SaveConfig ( Json out) const
inlineoverridevirtual

Save configuration to JSON object.

Parameters
outpointer to output JSON object

Implements xgboost::Configurable.

◆ SaveModel()

void xgboost::gbm::Dart::SaveModel ( Json out) const
inlineoverridevirtual

saves the model config to a JSON object

Parameters
outJSON container where to save the model to

Implements xgboost::Model.


The documentation for this class was generated from the following file: