BaselearnerCustomCpp {compboost} | R Documentation |
BaselearnerCustomCpp
creates a custom base-learner factory by
setting custom C++
functions. This factory object can be registered
within a base-learner list and then used for training.
S4
object.
BaselearnerCustomCpp$new(data_source, data_target, instantiate_data_ptr, train_ptr, predict_ptr)
data_source
[Data
Object]Data object which contains the source data.
data_target
[Data
Object]Data object which gets the transformed source data.
instantiate_data_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.
For an example see the extending compboost vignette or the function
getCustomCppExample
.
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/classblearnerfactory_1_1_custom_cpp_blearner_factory.html.
This class doesn't contain public fields.
getData()
Get the data matrix of the target data which is used for modeling.
transformData(X)
Transform a data matrix as defined within the factory. The argument has to be a matrix with one column.
summarizeFactory()
Summarize the base-learner factory object.
# 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") data.target = InMemoryData$new() # 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, data.target, dataFunSetter(), trainFunSetter(), predictFunSetter()) # Get the transformed data: custom.cpp.factory$getData() # Summarize factory: custom.cpp.factory$summarizeFactory() # Transform data manually: custom.cpp.factory$transformData(data.mat)