LossCustomCpp creates a custom loss by using Rcpp::XPtr to set C++ functions.

Format

S4 object.

Usage

LossCustomCpp$new(loss_ptr, grad_ptr, const_init_ptr)

Arguments

loss_ptr [externalptr]

External pointer to the C++ loss function.

grad_ptr [externalptr]

External pointer to the C++ gradient function.

const_init_ptr [externalptr]

External pointer to the C++ constant initialization function.

Details

For an example see the extending compboost vignette or the function getCustomCppExample(example = "loss").

This class is a wrapper around the pure C++ implementation. To see the functionality of the C++ class visit https://schalkdaniel.github.io/compboost/cpp_man/html/classloss_1_1_custom_cpp_loss.html.

Examples

# Load loss functions: Rcpp::sourceCpp(code = getCustomCppExample(example = "loss", silent = TRUE)) # Create new custom quadratic loss: my_cpp_loss = LossCustomCpp$new(lossFunSetter(), gradFunSetter(), constInitFunSetter())