Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
xgboost::LearnerConfiguration Class Reference
Inheritance diagram for xgboost::LearnerConfiguration:
xgboost::Learner xgboost::Model xgboost::Configurable dmlc::Serializable xgboost::LearnerIO xgboost::LearnerImpl

Public Member Functions

 LearnerConfiguration (std::vector< std::shared_ptr< DMatrix > > cache)
 
void Configure () override
 Configure Learner based on set parameters.
 
void CheckModelInitialized () const
 
void LoadConfig (Json const &in) override
 Load configuration from JSON object.
 
void SaveConfig (Json *p_out) const override
 Save configuration to JSON object.
 
void SetParam (const std::string &key, const std::string &value) override
 Set parameter for booster.
 
void SetParams (std::vector< std::pair< std::string, std::string > > const &args) override
 Set multiple parameters at once.
 
uint32_t GetNumFeature () const override
 Get the number of features of the booster.
 
void SetAttr (const std::string &key, const std::string &value) override
 Set additional attribute to the Booster.
 
bool GetAttr (const std::string &key, std::string *out) const override
 Get attribute from the booster. The property will be saved along the booster.
 
bool DelAttr (const std::string &key) override
 Delete an attribute from the booster.
 
void SetFeatureNames (std::vector< std::string > const &fn) override
 Set the feature names for current booster.
 
void GetFeatureNames (std::vector< std::string > *fn) const override
 Get the feature names for current booster.
 
void SetFeatureTypes (std::vector< std::string > const &ft) override
 Set the feature types for current booster.
 
void GetFeatureTypes (std::vector< std::string > *p_ft) const override
 Get the feature types for current booster.
 
std::vector< std::string > GetAttrNames () const override
 Get a vector of attribute names from the booster.
 
const std::map< std::string, std::string > & GetConfigurationArguments () const override
 Get configuration arguments currently stored by the learner.
 
Context const * Ctx () const override
 Return the context object of this Booster.
 
- Public Member Functions inherited from xgboost::Learner
 ~Learner () override
 virtual destructor
 
virtual void UpdateOneIter (int iter, std::shared_ptr< DMatrix > train)=0
 update the model for one iteration With the specified objective function.
 
virtual void BoostOneIter (int iter, std::shared_ptr< DMatrix > train, HostDeviceVector< GradientPair > *in_gpair)=0
 Do customized gradient boosting with in_gpair. in_gair can be mutated after this call.
 
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.
 
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.
 
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.
 
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.
 
virtual int32_t BoostedRounds () const =0
 
virtual std::uint32_t Groups () const =0
 Get the number of output groups from the model.
 
void LoadModel (Json const &in) override=0
 load the model from a JSON object
 
void SaveModel (Json *out) const override=0
 saves the model config to a JSON object
 
virtual void LoadModel (dmlc::Stream *fi)=0
 
virtual void SaveModel (dmlc::Stream *fo) const =0
 
virtual LearnerSlice (bst_layer_t begin, bst_layer_t end, bst_layer_t step, bool *out_of_bound)=0
 Slice the model.
 
virtual std::vector< std::string > DumpModel (const FeatureMap &fmap, bool with_stats, std::string format)=0
 dump the model in the requested format
 
virtual XGBAPIThreadLocalEntryGetThreadLocal () const =0
 
- Public Member Functions inherited from dmlc::Serializable
virtual ~Serializable ()
 virtual destructor
 
virtual void Load (Stream *fi)=0
 load the model from a stream
 
virtual void Save (Stream *fo) const =0
 saves the model to a stream
 

Protected Member Functions

void ConfigureModelParamWithoutBaseScore ()
 
void InitBaseScore (DMatrix const *p_fmat)
 Calculate the base_score based on input data.
 

Protected Attributes

std::atomic< bool > need_configuration_
 
std::map< std::string, std::string > cfg_
 
std::map< std::string, std::string > attributes_
 
std::vector< std::string > feature_names_
 
std::vector< std::string > feature_types_
 
common::Monitor monitor_
 
LearnerModelParamLegacy mparam_
 
LearnerModelParam learner_model_param_
 
LearnerTrainParam tparam_
 
PredictionContainer prediction_container_
 
std::vector< std::string > metric_names_
 
- Protected Attributes inherited from xgboost::Learner
std::unique_ptr< ObjFunctionobj_
 objective function
 
std::unique_ptr< GradientBoostergbm_
 The gradient booster used by the model.
 
std::vector< std::unique_ptr< Metric > > metrics_
 The evaluation metrics used to evaluate the model.
 
Context ctx_
 Training parameter.
 

Static Protected Attributes

static std::string const kEvalMetric {"eval_metric"}
 

Additional Inherited Members

- Static Public Member Functions inherited from xgboost::Learner
static LearnerCreate (const std::vector< std::shared_ptr< DMatrix > > &cache_data)
 Create a new instance of learner.
 

Member Function Documentation

◆ Configure()

void xgboost::LearnerConfiguration::Configure ( )
inlineoverridevirtual

Configure Learner based on set parameters.

Implements xgboost::Learner.

◆ Ctx()

Context const * xgboost::LearnerConfiguration::Ctx ( ) const
inlineoverridevirtual

Return the context object of this Booster.

Implements xgboost::Learner.

◆ DelAttr()

bool xgboost::LearnerConfiguration::DelAttr ( const std::string &  key)
inlineoverridevirtual

Delete an attribute from the booster.

Parameters
keyThe key of the attribute.
Returns
Whether the key was found among booster's attributes.

Implements xgboost::Learner.

◆ GetAttr()

bool xgboost::LearnerConfiguration::GetAttr ( const std::string &  key,
std::string *  out 
) const
inlineoverridevirtual

Get attribute from the booster. The property will be saved along the booster.

Parameters
keyThe key of the attribute.
outThe output value.
Returns
Whether the key exists among booster's attributes.

Implements xgboost::Learner.

◆ GetAttrNames()

std::vector< std::string > xgboost::LearnerConfiguration::GetAttrNames ( ) const
inlineoverridevirtual

Get a vector of attribute names from the booster.

Returns
vector of attribute name strings.

Implements xgboost::Learner.

◆ GetConfigurationArguments()

const std::map< std::string, std::string > & xgboost::LearnerConfiguration::GetConfigurationArguments ( ) const
inlineoverridevirtual

Get configuration arguments currently stored by the learner.

Returns
Key-value pairs representing configuration arguments

Implements xgboost::Learner.

Reimplemented in xgboost::LearnerImpl.

◆ GetFeatureNames()

void xgboost::LearnerConfiguration::GetFeatureNames ( std::vector< std::string > *  fn) const
inlineoverridevirtual

Get the feature names for current booster.

Parameters
fnOutput feature names

Implements xgboost::Learner.

◆ GetFeatureTypes()

void xgboost::LearnerConfiguration::GetFeatureTypes ( std::vector< std::string > *  ft) const
inlineoverridevirtual

Get the feature types for current booster.

Parameters
fnOutput feature types

Implements xgboost::Learner.

◆ GetNumFeature()

uint32_t xgboost::LearnerConfiguration::GetNumFeature ( ) const
inlineoverridevirtual

Get the number of features of the booster.

Returns
number of features

Implements xgboost::Learner.

◆ InitBaseScore()

void xgboost::LearnerConfiguration::InitBaseScore ( DMatrix const *  p_fmat)
inlineprotected

Calculate the base_score based on input data.

Parameters
p_fmatThe training DMatrix used to estimate the base score.

◆ LoadConfig()

void xgboost::LearnerConfiguration::LoadConfig ( Json const &  in)
inlineoverridevirtual

Load configuration from JSON object.

Parameters
inJSON object containing the configuration

Implements xgboost::Configurable.

◆ SaveConfig()

void xgboost::LearnerConfiguration::SaveConfig ( Json out) const
inlineoverridevirtual

Save configuration to JSON object.

Parameters
outpointer to output JSON object

Implements xgboost::Configurable.

◆ SetAttr()

void xgboost::LearnerConfiguration::SetAttr ( const std::string &  key,
const std::string &  value 
)
inlineoverridevirtual

Set additional attribute to the Booster.

The property will be saved along the booster.

Parameters
keyThe key of the property.
valueThe value of the property.

Implements xgboost::Learner.

◆ SetFeatureNames()

void xgboost::LearnerConfiguration::SetFeatureNames ( std::vector< std::string > const &  fn)
inlineoverridevirtual

Set the feature names for current booster.

Parameters
fnInput feature names

Implements xgboost::Learner.

◆ SetFeatureTypes()

void xgboost::LearnerConfiguration::SetFeatureTypes ( std::vector< std::string > const &  ft)
inlineoverridevirtual

Set the feature types for current booster.

Parameters
ftInput feature types.

Implements xgboost::Learner.

◆ SetParam()

void xgboost::LearnerConfiguration::SetParam ( const std::string &  key,
const std::string &  value 
)
inlineoverridevirtual

Set parameter for booster.

The property will NOT be saved along with booster

Parameters
keyThe key of parameter
valueThe value of parameter

Implements xgboost::Learner.

◆ SetParams()

void xgboost::LearnerConfiguration::SetParams ( std::vector< std::pair< std::string, std::string > > const &  args)
inlineoverridevirtual

Set multiple parameters at once.

Parameters
argsparameters.

Implements xgboost::Learner.


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