BaselearnerCustomCpp: Create custom cpp base-learner factory by using cpp functions...

Description Format Usage Arguments Details Fields Methods Examples

Description

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.

Format

S4 object.

Usage

1
2
BaselearnerCustomCpp$new(data_source, data_target, instantiate_data_ptr,
  train_ptr, predict_ptr)

Arguments

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.

Details

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.

Fields

This class doesn't contain public fields.

Methods

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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)

compboost documentation built on May 2, 2019, 6:40 a.m.