xgboost
|
interface of gradient boosting model. More...
#include <gbm.h>
Public Member Functions | |
~GradientBooster () override=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 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 boosting rounds m, (m+1), (m+2), ..., (n-1). More... | |
virtual std::int32_t | BoostedRounds () const =0 |
Return number of boosted rounds. More... | |
virtual bool | ModelFitted () const =0 |
Whether the model has already been trained. When tree booster is chosen, then returns true when there are existing trees. More... | |
virtual void | DoBoost (DMatrix *p_fmat, linalg::Matrix< GradientPair > *in_gpair, PredictionCacheEntry *, ObjFunction const *obj)=0 |
perform update to the model(boosting) More... | |
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. More... | |
virtual void | InplacePredict (std::shared_ptr< DMatrix >, float, PredictionCacheEntry *, bst_layer_t, bst_layer_t) const |
Inplace prediction. More... | |
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 More... | |
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 More... | |
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) * num_output_group * nsample, arranged in that order More... | |
virtual void | PredictInteractionContributions (DMatrix *dmat, HostDeviceVector< float > *out_contribs, bst_layer_t layer_begin, bst_layer_t layer_end, 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 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 | UseGPU () const =0 |
Whether the current booster uses GPU. More... | |
Public Member Functions inherited from xgboost::Model | |
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... | |
Public Member Functions inherited from xgboost::Configurable | |
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, Context const *ctx, LearnerModelParam const *learner_model_param) |
create a gradient booster from given name More... | |
Protected Member Functions | |
GradientBooster (Context const *ctx) | |
Protected Attributes | |
Context const * | ctx_ |
interface of gradient boosting model.
|
inlineexplicitprotected |
|
overridedefault |
virtual destructor
|
pure virtual |
Return number of boosted rounds.
|
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 |
|
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 |
prediction | The output prediction cache entry that needs to be updated. the booster may change content of gpair |
obj | The objective function used for boosting. |
|
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 |
|
inlinevirtual |
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. |
|
pure virtual |
load model from stream
fi | input stream. |
|
pure virtual |
Whether the model has already been trained. When tree booster is chosen, then returns true when there are existing trees.
|
pure virtual |
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. |
|
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 |
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 |
|
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 |
layer_begin | Beginning of boosted tree layer used for prediction. |
layer_end | End of booster layer. 0 means do not limit trees. |
|
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 |
layer_begin | Beginning of boosted tree layer used for prediction. |
layer_end | End of booster layer. 0 means do not limit trees. |
|
pure virtual |
save model to stream.
fo | output stream |
|
inlinevirtual |
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 |
|
pure virtual |
Whether the current booster uses GPU.
|
protected |