Medial Code Documentation
|
gradient boosted linear model More...
Public Member Functions | |
GBLinear (LearnerModelParam const *learner_model_param, Context const *ctx) | |
void | Configure (const Args &cfg) override |
Set the configuration of gradient boosting. User must call configure once before InitModel and Training. | |
int32_t | BoostedRounds () const override |
Return number of boosted rounds. | |
bool | ModelFitted () const override |
Whether the model has already been trained. | |
void | Load (dmlc::Stream *fi) override |
load model from stream | |
void | Save (dmlc::Stream *fo) const override |
save model to stream. | |
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 | LoadConfig (Json const &in) override |
Load configuration from JSON object. | |
void | SaveConfig (Json *p_out) const override |
Save configuration to JSON object. | |
void | DoBoost (DMatrix *p_fmat, HostDeviceVector< GradientPair > *in_gpair, PredictionCacheEntry *, ObjFunction const *) override |
perform update to the model(boosting) | |
void | PredictBatch (DMatrix *p_fmat, PredictionCacheEntry *predts, bool, bst_layer_t layer_begin, bst_layer_t) override |
Generate predictions for given feature matrix. | |
void | PredictInstance (const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, uint32_t layer_begin, uint32_t) override |
void | PredictLeaf (DMatrix *, HostDeviceVector< bst_float > *, unsigned, unsigned) override |
predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in gbtree predictor | |
void | PredictContribution (DMatrix *p_fmat, HostDeviceVector< bst_float > *out_contribs, bst_layer_t layer_begin, bst_layer_t, bool) 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, bool) override |
std::vector< std::string > | DumpModel (const FeatureMap &fmap, bool with_stats, std::string format) const override |
dump the model in the requested format | |
void | FeatureScore (std::string const &importance_type, common::Span< int32_t const > trees, std::vector< bst_feature_t > *out_features, std::vector< float > *out_scores) const override |
bool | UseGPU () const override |
Whether the current booster uses GPU. | |
![]() | |
~GradientBooster () override=default | |
virtual destructor | |
virtual void | Slice (bst_layer_t, bst_layer_t, bst_layer_t, GradientBooster *, bool *) const |
Slice a model using boosting index. | |
virtual void | InplacePredict (std::shared_ptr< DMatrix >, float, PredictionCacheEntry *, bst_layer_t, bst_layer_t) const |
Inplace prediction. | |
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 | |
Protected Member Functions | |
void | PredictBatchInternal (DMatrix *p_fmat, std::vector< bst_float > *out_preds) |
bool | CheckConvergence () |
void | LazySumWeights (DMatrix *p_fmat) |
void | Pred (const SparsePage::Inst &inst, bst_float *preds, int gid, bst_float base) |
![]() | |
GradientBooster (Context const *ctx) | |
Protected Attributes | |
LearnerModelParam const * | learner_model_param_ |
GBLinearModel | model_ |
GBLinearModel | previous_model_ |
GBLinearTrainParam | param_ |
std::unique_ptr< LinearUpdater > | updater_ |
double | sum_instance_weight_ {} |
bool | sum_weight_complete_ {false} |
common::Monitor | monitor_ |
bool | is_converged_ {false} |
![]() | |
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 | |
gradient boosted linear model
|
inlineoverridevirtual |
Return number of boosted rounds.
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
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.
|
inlineoverridevirtual |
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 |
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.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Load configuration from JSON object.
in | JSON object containing the configuration |
Implements xgboost::Configurable.
|
inlineoverridevirtual |
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.
|
inlineoverridevirtual |
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 |
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. |
Implements xgboost::GradientBooster.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Save configuration to JSON object.
out | pointer to output JSON object |
Implements xgboost::Configurable.
|
inlineoverridevirtual |
saves the model config to a JSON object
out | JSON container where to save the model to |
Implements xgboost::Model.
|
inlineoverridevirtual |
Whether the current booster uses GPU.
Implements xgboost::GradientBooster.