xgboost
|
Learner class that does training and prediction. This is the user facing module of xgboost training. The Load/Save function corresponds to the model used in python/R. More...
#include <learner.h>
Public Member Functions | |
~Learner () override | |
virtual destructor More... | |
virtual void | Configure ()=0 |
Configure Learner based on set parameters. More... | |
virtual void | UpdateOneIter (std::int32_t iter, std::shared_ptr< DMatrix > train)=0 |
update the model for one iteration With the specified objective function. More... | |
virtual void | BoostOneIter (std::int32_t iter, std::shared_ptr< DMatrix > train, linalg::Matrix< GradientPair > *in_gpair)=0 |
Do customized gradient boosting with in_gpair. More... | |
virtual std::string | EvalOneIter (int iter, const std::vector< std::shared_ptr< DMatrix >> &data_sets, const std::vector< std::string > &data_names)=0 |
evaluate the model for specific iteration using the configured metrics. More... | |
virtual void | Predict (std::shared_ptr< DMatrix > data, bool output_margin, HostDeviceVector< bst_float > *out_preds, bst_layer_t layer_begin, bst_layer_t layer_end, bool training=false, bool pred_leaf=false, bool pred_contribs=false, bool approx_contribs=false, bool pred_interactions=false)=0 |
get prediction given the model. More... | |
virtual void | InplacePredict (std::shared_ptr< DMatrix > p_m, PredictionType type, float missing, HostDeviceVector< float > **out_preds, bst_layer_t layer_begin, bst_layer_t layer_end)=0 |
Inplace prediction. More... | |
virtual void | CalcFeatureScore (std::string const &importance_type, common::Span< int32_t const > trees, std::vector< bst_feature_t > *features, std::vector< float > *scores)=0 |
Calculate feature score. See doc in C API for outputs. More... | |
virtual int32_t | BoostedRounds () const =0 |
virtual std::uint32_t | Groups () const =0 |
Get the number of output groups from the model. More... | |
void | LoadModel (Json const &in) override=0 |
load the model from a JSON object More... | |
void | SaveModel (Json *out) const override=0 |
saves the model config to a JSON object More... | |
virtual void | LoadModel (dmlc::Stream *fi)=0 |
virtual void | SaveModel (dmlc::Stream *fo) const =0 |
virtual void | SetParams (Args const &args)=0 |
Set multiple parameters at once. More... | |
virtual void | SetParam (const std::string &key, const std::string &value)=0 |
Set parameter for booster. More... | |
virtual uint32_t | GetNumFeature () const =0 |
Get the number of features of the booster. More... | |
virtual void | SetAttr (const std::string &key, const std::string &value)=0 |
Set additional attribute to the Booster. More... | |
virtual bool | GetAttr (const std::string &key, std::string *out) const =0 |
Get attribute from the booster. The property will be saved along the booster. More... | |
virtual bool | DelAttr (const std::string &key)=0 |
Delete an attribute from the booster. More... | |
virtual std::vector< std::string > | GetAttrNames () const =0 |
Get a vector of attribute names from the booster. More... | |
virtual void | SetFeatureNames (std::vector< std::string > const &fn)=0 |
Set the feature names for current booster. More... | |
virtual void | GetFeatureNames (std::vector< std::string > *fn) const =0 |
Get the feature names for current booster. More... | |
virtual void | SetFeatureTypes (std::vector< std::string > const &ft)=0 |
Set the feature types for current booster. More... | |
virtual void | GetFeatureTypes (std::vector< std::string > *ft) const =0 |
Get the feature types for current booster. More... | |
virtual Learner * | Slice (bst_layer_t begin, bst_layer_t end, bst_layer_t step, bool *out_of_bound)=0 |
Slice the model. More... | |
virtual std::vector< std::string > | DumpModel (const FeatureMap &fmap, bool with_stats, std::string format)=0 |
dump the model in the requested format More... | |
virtual XGBAPIThreadLocalEntry & | GetThreadLocal () const =0 |
virtual void | Reset ()=0 |
Reset the booster object to release data caches used for training. More... | |
virtual Context const * | Ctx () const =0 |
Return the context object of this Booster. More... | |
virtual const std::map< std::string, std::string > & | GetConfigurationArguments () const =0 |
Get configuration arguments currently stored by the learner. More... | |
![]() | |
virtual | ~Model ()=default |
![]() | |
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 Learner * | Create (const std::vector< std::shared_ptr< DMatrix > > &cache_data) |
Create a new instance of learner. More... | |
Protected Attributes | |
std::unique_ptr< ObjFunction > | obj_ |
objective function More... | |
std::unique_ptr< GradientBooster > | gbm_ |
The gradient booster used by the model. More... | |
std::vector< std::unique_ptr< Metric > > | metrics_ |
The evaluation metrics used to evaluate the model. More... | |
Context | ctx_ |
Training parameter. More... | |
Learner class that does training and prediction. This is the user facing module of xgboost training. The Load/Save function corresponds to the model used in python/R.
|
override |
virtual destructor
|
pure virtual |
|
pure virtual |
Do customized gradient boosting with in_gpair.
iter | current iteration number |
train | reference to the data matrix. |
in_gpair | The input gradient statistics. |
|
pure virtual |
Calculate feature score. See doc in C API for outputs.
|
pure virtual |
Configure Learner based on set parameters.
|
static |
Create a new instance of learner.
cache_data | The matrix to cache the prediction. |
|
pure virtual |
Return the context object of this Booster.
|
pure virtual |
Delete an attribute from the booster.
key | The key of the attribute. |
|
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 |
evaluate the model for specific iteration using the configured metrics.
iter | iteration number |
data_sets | datasets to be evaluated. |
data_names | name of each dataset |
|
pure virtual |
Get attribute from the booster. The property will be saved along the booster.
key | The key of the attribute. |
out | The output value. |
|
pure virtual |
Get a vector of attribute names from the booster.
|
pure virtual |
Get configuration arguments currently stored by the learner.
|
pure virtual |
Get the feature names for current booster.
fn | Output feature names |
|
pure virtual |
Get the feature types for current booster.
fn | Output feature types |
|
pure virtual |
Get the number of features of the booster.
|
pure virtual |
|
pure virtual |
Get the number of output groups from the model.
|
pure virtual |
Inplace prediction.
p_fmat | A proxy DMatrix that contains the data and related meta info. | |
type | Prediction type. | |
missing | Missing value in the data. | |
[in,out] | out_preds | Pointer to output prediction vector. |
layer_begin | Beginning of boosted tree layer used for prediction. | |
layer_end | End of booster layer. 0 means do not limit trees. |
|
pure virtual |
|
overridepure virtual |
load the model from a JSON object
in | JSON object where to load the model from |
Implements xgboost::Model.
|
pure virtual |
get prediction given the model.
data | input data |
output_margin | whether to only predict margin value instead of transformed prediction |
out_preds | output vector that stores the prediction |
layer_begin | Beginning of boosted tree layer used for prediction. |
layer_end | End of booster layer. 0 means do not limit trees. |
training | Whether the prediction result is used for training |
pred_leaf | whether to only predict the leaf index of each tree in a boosted tree predictor |
pred_contribs | whether to only predict the feature contributions |
approx_contribs | whether to approximate the feature contributions for speed |
pred_interactions | whether to compute the feature pair contributions |
|
pure virtual |
Reset the booster object to release data caches used for training.
|
pure virtual |
|
overridepure virtual |
saves the model config to a JSON object
out | JSON container where to save the model to |
Implements xgboost::Model.
|
pure virtual |
Set additional attribute to the Booster.
The property will be saved along the booster.
key | The key of the property. |
value | The value of the property. |
|
pure virtual |
Set the feature names for current booster.
fn | Input feature names |
|
pure virtual |
Set the feature types for current booster.
ft | Input feature types. |
|
pure virtual |
Set parameter for booster.
The property will NOT be saved along with booster
key | The key of parameter |
value | The value of parameter |
|
pure virtual |
Set multiple parameters at once.
args | parameters. |
|
pure virtual |
Slice the model.
See InplacePredict for layer parameters.
step | step size between slice. |
out_of_bound | Return true if end layer is out of bound. |
|
pure virtual |
update the model for one iteration With the specified objective function.
iter | current iteration number |
train | reference to the data matrix. |
|
protected |
Training parameter.
|
protected |
The gradient booster used by the model.
|
protected |
The evaluation metrics used to evaluate the model.
|
protected |
objective function