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.

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())