Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes
xgboost::gbm::GBLinear Class Reference

gradient boosted linear model More...

Inheritance diagram for xgboost::gbm::GBLinear:
xgboost::GradientBooster xgboost::Model xgboost::Configurable

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.
 
- Public Member Functions inherited from xgboost::GradientBooster
 ~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)
 
- Protected Member Functions inherited from xgboost::GradientBooster
 GradientBooster (Context const *ctx)
 

Protected Attributes

LearnerModelParam const * learner_model_param_
 
GBLinearModel model_
 
GBLinearModel previous_model_
 
GBLinearTrainParam param_
 
std::unique_ptr< LinearUpdaterupdater_
 
double sum_instance_weight_ {}
 
bool sum_weight_complete_ {false}
 
common::Monitor monitor_
 
bool is_converged_ {false}
 
- 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
 

Detailed Description

gradient boosted linear model

Member Function Documentation

◆ BoostedRounds()

int32_t xgboost::gbm::GBLinear::BoostedRounds ( ) const
inlineoverridevirtual

Return number of boosted rounds.

Implements xgboost::GradientBooster.

◆ Configure()

void xgboost::gbm::GBLinear::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.

◆ DoBoost()

void xgboost::gbm::GBLinear::DoBoost ( DMatrix p_fmat,
HostDeviceVector< GradientPair > *  in_gpair,
PredictionCacheEntry ,
ObjFunction const *  obj 
)
inlineoverridevirtual

perform update to the model(boosting)

Parameters
p_fmatfeature matrix that provide access to features
in_gpairaddress of the gradient pair statistics of the data
predictionThe output prediction cache entry that needs to be updated. the booster may change content of gpair

Implements xgboost::GradientBooster.

◆ DumpModel()

std::vector< std::string > xgboost::gbm::GBLinear::DumpModel ( const FeatureMap fmap,
bool  with_stats,
std::string  format 
) const
inlineoverridevirtual

dump the model in the requested format

Parameters
fmapfeature map that may help give interpretations of feature
with_statsextra statistics while dumping model
formatthe format to dump the model in
Returns
a vector of dump for boosters.

Implements xgboost::GradientBooster.

◆ FeatureScore()

void xgboost::gbm::GBLinear::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
inlineoverridevirtual

◆ Load()

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

load model from stream

Parameters
fiinput stream.

Implements xgboost::GradientBooster.

◆ LoadConfig()

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

Load configuration from JSON object.

Parameters
inJSON object containing the configuration

Implements xgboost::Configurable.

◆ LoadModel()

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

load the model from a JSON object

Parameters
inJSON object where to load the model from

Implements xgboost::Model.

◆ ModelFitted()

bool xgboost::gbm::GBLinear::ModelFitted ( ) const
inlineoverridevirtual

Whether the model has already been trained.

When tree booster is chosen, then returns true when there are existing trees.

Implements xgboost::GradientBooster.

◆ PredictBatch()

void xgboost::gbm::GBLinear::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::GBLinear::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.

◆ PredictInteractionContributions()

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

◆ PredictLeaf()

void xgboost::gbm::GBLinear::PredictLeaf ( DMatrix dmat,
HostDeviceVector< bst_float > *  out_preds,
unsigned  layer_begin,
unsigned  layer_end 
)
inlineoverridevirtual

predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in gbtree predictor

Parameters
dmatfeature matrix
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.

Implements xgboost::GradientBooster.

◆ Save()

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

save model to stream.

Parameters
fooutput stream

Implements xgboost::GradientBooster.

◆ SaveConfig()

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

Save configuration to JSON object.

Parameters
outpointer to output JSON object

Implements xgboost::Configurable.

◆ SaveModel()

void xgboost::gbm::GBLinear::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.

◆ UseGPU()

bool xgboost::gbm::GBLinear::UseGPU ( ) const
inlineoverridevirtual

Whether the current booster uses GPU.

Implements xgboost::GradientBooster.


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