Skip to contents

This class defines a custom base learner factory by passing pointers to C++ functions for instantiation, fitting, and predicting.

Format

S4 object.

Arguments

data_source

(InMemoryData)
Uninitialized data object used to store the meta data. Note: At the moment, just in memory storing is supported, see ?InMemorydata for details.

instantiate_ptr

(externalptr)
External pointer to the C++ instantiate data function.

train_ptr

(externalptr)
External pointer to the C++ train function.

predict_ptr

(externalptr)
External pointer to the C++ predict function.

Usage


BaselearnerCustomCpp$new(data_source, list(instantiate_ptr, train_ptr, predict_ptr))

Details

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

Fields

This class doesn't contain public fields.

Methods

  • $summarizeFactory(): () -> ()

  • $transfromData(newdata): list(InMemoryData) -> matrix()

  • $getMeta(): () -> list()

Inherited methods from Baselearner

  • $getData(): () -> matrix()

  • $getDF(): () -> integer()

  • $getPenalty(): () -> numeric()

  • $getPenaltyMat(): () -> matrix()

  • $getFeatureName(): () -> character()

  • $getModelName(): () -> character()

  • $getBaselearnerId(): () -> character()

Examples

if (FALSE) {
# Sample data:
data_mat = cbind(1, 1:10)
y = 2 + 3 * 1:10

# Create new data object:
data_source = InMemoryData$new(data_mat, "my_data_name")

# Source the external pointer exposed by using XPtr:
Rcpp::sourceCpp(code = getCustomCppExample(silent = TRUE))

# Create new linear base learner:
custom_cpp_factory = BaselearnerCustomCpp$new(data_source,
  list(instantiate_ptr = dataFunSetter(), train_ptr = trainFunSetter(),
    predict_ptr = predictFunSetter()))

# Get the transformed data:
custom_cpp_factory$getData()

# Summarize factory:
custom_cpp_factory$summarizeFactory()
}