BaselearnerPolynomial creates a polynomial base-learner factory object which can be registered within a base-learner list and then used for training.

Format

S4 object.

Usage

BaselearnerPolynomial$new(data_source, data_target, list(degree, intercept))
BaselearnerPolynomial$new(data_source, data_target, blearner_type, list(degree, intercept))

Arguments

data_source [Data Object]

Data object which contains the source data.

data_target [Data Object]

Data object which gets the transformed source data.

degree [integer(1)]

This argument is used for transforming the source data. Each element is taken to the power of the degree argument.

intercept [logical(1)]

Indicating whether an intercept should be added or not. Default is set to TRUE.

Details

The polynomial base-learner factory takes any matrix which the user wants to pass the number of columns indicates how much parameter are estimated. Note that the intercept isn't added by default. To get an intercept add a column of ones to the source data matrix.

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_polynomial_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

# Sample data: data_mat = cbind(1:10) # Create new data object: data_source = InMemoryData$new(data_mat, "my_data_name") data_target1 = InMemoryData$new() data_target2 = InMemoryData$new() # Create new linear base-learner factory: lin_factory = BaselearnerPolynomial$new(data_source, data_target1, list(degree = 2, intercept = FALSE)) lin_factory_int = BaselearnerPolynomial$new(data_source, data_target2, list(degree = 2, intercept = TRUE)) # Get the transformed data: lin_factory$getData()
#> [,1] #> [1,] 1 #> [2,] 4 #> [3,] 9 #> [4,] 16 #> [5,] 25 #> [6,] 36 #> [7,] 49 #> [8,] 64 #> [9,] 81 #> [10,] 100
lin_factory_int$getData()
#> [,1] [,2] #> [1,] 1 1 #> [2,] 1 1 #> [3,] 1 1 #> [4,] 1 1 #> [5,] 1 1 #> [6,] 1 1 #> [7,] 1 1 #> [8,] 1 1 #> [9,] 1 1 #> [10,] 1 1
# Summarize factory: lin_factory$summarizeFactory()
#> Quadratic base-learner factory: #> - Name of the used data: my_data_name #> - Factory creates the following base-learner: polynomial_degree_2
# Transform data manually: lin_factory$transformData(data_mat)
#> [,1] #> [1,] 1 #> [2,] 4 #> [3,] 9 #> [4,] 16 #> [5,] 25 #> [6,] 36 #> [7,] 49 #> [8,] 64 #> [9,] 81 #> [10,] 100
lin_factory_int$transformData(data_mat)
#> [,1] [,2] #> [1,] 1 1 #> [2,] 1 4 #> [3,] 1 9 #> [4,] 1 16 #> [5,] 1 25 #> [6,] 1 36 #> [7,] 1 49 #> [8,] 1 64 #> [9,] 1 81 #> [10,] 1 100