xgboost
|
interface of gradient boosting model. More...
#include <gbm.h>
Public Member Functions | |
virtual | ~GradientBooster ()=default |
virtual destructor More... | |
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 Training. More... | |
virtual void | Load (dmlc::Stream *fi)=0 |
load model from stream More... | |
virtual void | Save (dmlc::Stream *fo) const =0 |
save model to stream. More... | |
virtual bool | AllowLazyCheckPoint () const |
whether the model allow lazy checkpoint return true if model is only updated in DoBoost after all Allreduce calls More... | |
virtual void | DoBoost (DMatrix *p_fmat, HostDeviceVector< GradientPair > *in_gpair, ObjFunction *obj=nullptr)=0 |
perform update to the model(boosting) More... | |
virtual void | PredictBatch (DMatrix *dmat, HostDeviceVector< bst_float > *out_preds, bool training, unsigned ntree_limit=0)=0 |
generate predictions for given feature matrix More... | |
virtual void | PredictInstance (const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, unsigned ntree_limit=0)=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 More... | |
virtual void | PredictLeaf (DMatrix *dmat, std::vector< bst_float > *out_preds, unsigned ntree_limit=0)=0 |
predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in gbtree predictor More... | |
virtual void | PredictContribution (DMatrix *dmat, std::vector< bst_float > *out_contribs, unsigned ntree_limit=0, 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) * num_output_group * nsample, arranged in that order More... | |
virtual void | PredictInteractionContributions (DMatrix *dmat, std::vector< bst_float > *out_contribs, unsigned ntree_limit, bool approximate)=0 |
virtual std::vector< std::string > | DumpModel (const FeatureMap &fmap, bool with_stats, std::string format) const =0 |
dump the model in the requested format More... | |
virtual bool | UseGPU () const =0 |
Whether the current booster uses GPU. More... | |
![]() | |
virtual | ~Model ()=default |
virtual void | LoadModel (Json const &in)=0 |
load the model from a json object More... | |
virtual void | SaveModel (Json *out) const =0 |
saves the model config to a json object More... | |
![]() | |
virtual | ~Configurable ()=default |
virtual void | LoadConfig (Json const &in)=0 |
Load configuration from JSON object. More... | |
virtual void | SaveConfig (Json *out) const =0 |
Save configuration to JSON object. More... | |
Static Public Member Functions | |
static GradientBooster * | Create (const std::string &name, GenericParameter const *generic_param, LearnerModelParam const *learner_model_param, const std::vector< std::shared_ptr< DMatrix > > &cache_mats) |
create a gradient booster from given name More... | |
static void | AssertGPUSupport () |
Protected Attributes | |
GenericParameter const * | generic_param_ |
interface of gradient boosting model.
|
virtualdefault |
virtual destructor
|
inlinevirtual |
whether the model allow lazy checkpoint return true if model is only updated in DoBoost after all Allreduce calls
|
inlinestatic |
|
pure virtual |
Set the configuration of gradient boosting. User must call configure once before InitModel and Training.
cfg | configurations on both training and model parameters. |
|
static |
create a gradient booster from given name
name | name of gradient booster |
generic_param | Pointer to runtime parameters |
learner_model_param | pointer to global model parameters |
cache_mats | The cache data matrix of the Booster. |
|
pure virtual |
perform update to the model(boosting)
p_fmat | feature matrix that provide access to features |
in_gpair | address of the gradient pair statistics of the data |
obj | The objective function, optional, can be nullptr when use customized version the booster may change content of gpair |
|
pure virtual |
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 |
|
pure virtual |
load model from stream
fi | input stream. |
|
pure virtual |
generate predictions for given feature matrix
dmat | feature matrix |
out_preds | output vector to hold the predictions |
ntree_limit | limit the number of trees used in prediction, when it equals 0, this means we do not limit number of trees, this parameter is only valid for gbtree, but not for gblinear |
|
pure virtual |
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 |
ntree_limit | limit the number of trees used in prediction, when it equals 0, this means we do not limit number of trees |
approximate | use a faster (inconsistent) approximation of SHAP values |
condition | condition on the condition_feature (0=no, -1=cond off, 1=cond on). |
condition_feature | feature to condition on (i.e. fix) during calculations |
|
pure virtual |
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
inst | the instance you want to predict |
out_preds | output vector to hold the predictions |
ntree_limit | limit the number of trees used in prediction |
|
pure virtual |
|
pure virtual |
predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in gbtree predictor
dmat | feature matrix |
out_preds | output vector to hold the predictions |
ntree_limit | limit the number of trees used in prediction, when it equals 0, this means we do not limit number of trees, this parameter is only valid for gbtree, but not for gblinear |
|
pure virtual |
save model to stream.
fo | output stream |
|
pure virtual |
Whether the current booster uses GPU.
|
protected |