Base learner factory list to define the set of base learners
Source:R/RcppExports.R
BlearnerFactoryList.Rd
BlearnerFactoryList
creates an object in which base learner factories
can be registered. This object can then be passed to compboost as set of
base learner which is used by the optimizer to get the new best
base learner.
Format
S4 object.
Usage
BlearnerFactoryList$new()
Methods
registerFactory(BaselearnerFactory)
Takes a object of the class
BaseLearnerFactory
and adds this factory to the set of base learner.printRegisteredFactories()
Get all registered factories.
clearRegisteredFactories()
Remove all registered factories. Note that the factories are not deleted, just removed from the map.
getModelFrame()
Get each target data matrix parsed to one big matrix.
getNumberOfRegisteredFactories()
Get the number of registered factories.
Examples
# Sample data:
data_mat = cbind(1:10)
# Create new data object:
data_source = InMemoryData$new(data_mat, "my_data_name")
lin_factory = BaselearnerPolynomial$new(data_source,
list(degree = 1, intercept = TRUE))
poly_factory = BaselearnerPolynomial$new(data_source,
list(degree = 2, intercept = TRUE))
# Create new base learner list:
my_bl_list = BlearnerFactoryList$new()
# Register factories:
my_bl_list$registerFactory(lin_factory)
my_bl_list$registerFactory(poly_factory)
# Get registered factories:
my_bl_list$printRegisteredFactories()
#> Registered base-learner:
#> - my_data_name_poly1
#> - my_data_name_poly2
# Get all target data matrices in one big matrix:
my_bl_list$getModelFrame()
#> $colnames
#> [1] "my_data_name_poly1x11" "my_data_name_poly1x12" "my_data_name_poly2x11"
#> [4] "my_data_name_poly2x12" "my_data_name_poly2x13"
#>
#> $model_frame
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 1 1 1 1
#> [2,] 1 2 1 2 4
#> [3,] 1 3 1 3 9
#> [4,] 1 4 1 4 16
#> [5,] 1 5 1 5 25
#> [6,] 1 6 1 6 36
#> [7,] 1 7 1 7 49
#> [8,] 1 8 1 8 64
#> [9,] 1 9 1 9 81
#> [10,] 1 10 1 10 100
#>
# Clear list:
my_bl_list$clearRegisteredFactories()
# Get number of registered factories:
my_bl_list$getNumberOfRegisteredFactories()
#> [1] 0