xgboost
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
xgboost::ObjFunction Class Referenceabstract

interface of objective function More...

#include <objective.h>

Inheritance diagram for xgboost::ObjFunction:
Inheritance graph
Collaboration diagram for xgboost::ObjFunction:
Collaboration graph

Public Member Functions

 ~ObjFunction () override=default
 virtual destructor More...
 
virtual void Configure (const std::vector< std::pair< std::string, std::string > > &args)=0
 Configure the objective with the specified parameters. More...
 
virtual void GetGradient (const HostDeviceVector< bst_float > &preds, const MetaInfo &info, std::int32_t iter, linalg::Matrix< GradientPair > *out_gpair)=0
 Get gradient over each of predictions, given existing information. More...
 
virtual const char * DefaultEvalMetric () const =0
 
virtual Json DefaultMetricConfig () const
 Return the configuration for the default metric. More...
 
virtual void PredTransform (HostDeviceVector< bst_float > *) const
 transform prediction values, this is only called when Prediction is called More...
 
virtual void EvalTransform (HostDeviceVector< bst_float > *io_preds)
 transform prediction values, this is only called when Eval is called, usually it redirect to PredTransform More...
 
virtual bst_float ProbToMargin (bst_float base_score) const
 transform probability value back to margin this is used to transform user-set base_score back to margin used by gradient boosting More...
 
virtual void InitEstimation (MetaInfo const &info, linalg::Tensor< float, 1 > *base_score) const
 Make initialize estimation of prediction. More...
 
virtual struct ObjInfo Task () const =0
 Return task of this objective. More...
 
virtual bst_target_t Targets (MetaInfo const &info) const
 Return number of targets for input matrix. Right now XGBoost supports only multi-target regression. More...
 
virtual void UpdateTreeLeaf (HostDeviceVector< bst_node_t > const &, MetaInfo const &, float, HostDeviceVector< float > const &, std::int32_t, RegTree *) const
 Update the leaf values after a tree is built. Needed for objectives with 0 hessian. 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 constexpr float DefaultBaseScore ()
 
static ObjFunctionCreate (const std::string &name, Context const *ctx)
 Create an objective function according to name. More...
 
static std::string GetSyclImplementationName (const std::string &name)
 Return sycl specific implementation name if possible. More...
 

Protected Attributes

Context const * ctx_
 

Detailed Description

interface of objective function

Constructor & Destructor Documentation

◆ ~ObjFunction()

xgboost::ObjFunction::~ObjFunction ( )
overridedefault

virtual destructor

Member Function Documentation

◆ Configure()

virtual void xgboost::ObjFunction::Configure ( const std::vector< std::pair< std::string, std::string > > &  args)
pure virtual

Configure the objective with the specified parameters.

Parameters
argsarguments to the objective function.

◆ Create()

static ObjFunction* xgboost::ObjFunction::Create ( const std::string &  name,
Context const *  ctx 
)
static

Create an objective function according to name.

Parameters
ctxPointer to runtime parameters.
nameName of the objective.

◆ DefaultBaseScore()

static constexpr float xgboost::ObjFunction::DefaultBaseScore ( )
inlinestaticconstexpr

◆ DefaultEvalMetric()

virtual const char* xgboost::ObjFunction::DefaultEvalMetric ( ) const
pure virtual
Returns
the default evaluation metric for the objective

◆ DefaultMetricConfig()

virtual Json xgboost::ObjFunction::DefaultMetricConfig ( ) const
inlinevirtual

Return the configuration for the default metric.

◆ EvalTransform()

virtual void xgboost::ObjFunction::EvalTransform ( HostDeviceVector< bst_float > *  io_preds)
inlinevirtual

transform prediction values, this is only called when Eval is called, usually it redirect to PredTransform

Parameters
io_predsprediction values, saves to this vector as well

◆ GetGradient()

virtual void xgboost::ObjFunction::GetGradient ( const HostDeviceVector< bst_float > &  preds,
const MetaInfo info,
std::int32_t  iter,
linalg::Matrix< GradientPair > *  out_gpair 
)
pure virtual

Get gradient over each of predictions, given existing information.

Parameters
predsprediction of current round
infoinformation about labels, weights, groups in rank
iterationcurrent iteration number.
out_gpairoutput of get gradient, saves gradient and second order gradient in

◆ GetSyclImplementationName()

static std::string xgboost::ObjFunction::GetSyclImplementationName ( const std::string &  name)
static

Return sycl specific implementation name if possible.

Parameters
nameName of the objective.

◆ InitEstimation()

virtual void xgboost::ObjFunction::InitEstimation ( MetaInfo const &  info,
linalg::Tensor< float, 1 > *  base_score 
) const
virtual

Make initialize estimation of prediction.

Parameters
infoMetaInfo that contains label.
base_scoreOutput estimation.

◆ PredTransform()

virtual void xgboost::ObjFunction::PredTransform ( HostDeviceVector< bst_float > *  ) const
inlinevirtual

transform prediction values, this is only called when Prediction is called

Parameters
io_predsprediction values, saves to this vector as well

◆ ProbToMargin()

virtual bst_float xgboost::ObjFunction::ProbToMargin ( bst_float  base_score) const
inlinevirtual

transform probability value back to margin this is used to transform user-set base_score back to margin used by gradient boosting

Returns
transformed value

◆ Targets()

virtual bst_target_t xgboost::ObjFunction::Targets ( MetaInfo const &  info) const
inlinevirtual

Return number of targets for input matrix. Right now XGBoost supports only multi-target regression.

◆ Task()

virtual struct ObjInfo xgboost::ObjFunction::Task ( ) const
pure virtual

Return task of this objective.

◆ UpdateTreeLeaf()

virtual void xgboost::ObjFunction::UpdateTreeLeaf ( HostDeviceVector< bst_node_t > const &  ,
MetaInfo const &  ,
float  ,
HostDeviceVector< float > const &  ,
std::int32_t  ,
RegTree  
) const
inlinevirtual

Update the leaf values after a tree is built. Needed for objectives with 0 hessian.

Note that the leaf update is not well defined for distributed training as XGBoost computes only an average of quantile between workers. This breaks when some leaf have no sample assigned in a local worker.

Parameters
positionThe leaf index for each rows.
infoMetaInfo providing labels and weights.
learning_rateThe learning rate for current iteration.
predictionModel prediction after transformation.
group_idxThe group index for this tree, 0 when it's not multi-target or multi-class.
p_treeTree that needs to be updated.

Member Data Documentation

◆ ctx_

Context const* xgboost::ObjFunction::ctx_
protected

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