XGBMetricForOrderedLogit: Custom Objective/Evaluate Functions Class for XGBoost

Description Details Public fields Active bindings Methods Note

Description

Custom Objective/Evaluate Functions Class for XGBoost

Custom Objective/Evaluate Functions Class for XGBoost

Details

R6 Class defining custom Objective/Evaluate for XGBoost

Public fields

Criterion

values between each labels for Ordered Logit Model

notchdiff_eval

width of notch when evaluating hit ratio

Active bindings

Criterion

values between each labels for Ordered Logit Model

notchdiff_eval

width of notch when evaluating hit ratio

Methods

Public methods


Method set_criterion()

Set Criterions between each labels for Ordered Logit Model

Usage
XGBMetricForOrderedLogit$set_criterion(x)
Arguments
x

A double vector


Method return_criterion()

Return criterions between each labels for Ordered Logit Model

Usage
XGBMetricForOrderedLogit$return_criterion()
Returns

Criterion set in this class


Method set_notchdiff_eval()

Set notch width when evaluating hit ratio by eval_hitratio()

Usage
XGBMetricForOrderedLogit$set_notchdiff_eval(x)
Arguments
x

An integer, notch width when evaluate hit ratio


Method return_notchdiff_eval()

Return notch width

Usage
XGBMetricForOrderedLogit$return_notchdiff_eval()
Returns

private$notchdiff_eval


Method pred_class_criterion()

Function to predict labels comparing preds and criterions (not maximum probability)

Usage
XGBMetricForOrderedLogit$pred_class_criterion(preds)
Arguments
preds

A double vector, margin score from xgboost before logistic transformation

Returns

Integer label, if [-Inf, criterion[1]) label is 1, else if [criterion[1], criterion[2]), label is 2, ...


Method pred_class_maxprob()

Function to predict labels at maximum probability

Usage
XGBMetricForOrderedLogit$pred_class_maxprob(preds)
Arguments
preds

A double vector, margin score from xgboost before logistic transformation

Returns

Integer label at max probability


Method obj_ordered_logit()

Custom Objective Function of Ordered Logit Model https://github.com/dmlc/xgboost/blob/master/R-package/demo/custom_objective.R

Usage
XGBMetricForOrderedLogit$obj_ordered_logit(preds, dtrain)
Arguments
preds

A double vector, margin score at t-1

dtrain

A xgb.DMatrix created by xgboost::xgb.DMatrix

Returns

A named list(both double vector). $grad gradient of loss function. $hess hessian of loss function.


Method eval_logloss()

Custom Evaluate Function of Ordered Logit Model (logloss) https://github.com/dmlc/xgboost/blob/master/R-package/demo/custom_objective.R

Usage
XGBMetricForOrderedLogit$eval_logloss(preds, dtrain)
Arguments
preds

A double vector, margin score

dtrain

A xgb.DMatrix created by xgboost::xgb.DMatrix

Returns

A named list(both double vector). $metric name of metric. $value value of metric.


Method eval_hitratio()

Custom Evaluate Function of Ordered Logit Model (hit ratio) https://github.com/dmlc/xgboost/blob/master/R-package/demo/custom_objective.R

Usage
XGBMetricForOrderedLogit$eval_hitratio(preds, dtrain)
Arguments
preds

A double vector, margin score

dtrain

A xgb.DMatrix created by xgboost::xgb.DMatrix

Returns

A named list(both double vector). $metric name of metric. $value value of metric.


Method clone()

The objects of this class are cloneable with this method.

Usage
XGBMetricForOrderedLogit$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Note

Add -Inf/Inf both side of input x

x is sorted ascending criterion[1] = -Inf, criterion[2] = x[1], ... criterion[nClass] = x[nClass - 1], criterion[nClass + 1] = Inf

x = 1 -> hit ratio is calculated by |act - est| < x / length(act)

grad, hess were referred to URL below. https://www.slideshare.net/TakujiTahara/201200229-lt-dsb2019-ordered-logit-model-for-qwk-tawara#23

self$notchdiff_eval is set by set_notchdiff_eval


atamakita/xgboostOLR documentation built on Aug. 8, 2020, 5:39 p.m.