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

Format

S4 object.

Usage

BaselearnerPSpline$new(data_source, data_target, list(degree, n_knots, penalty,
  differences))

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)]

Degree of the spline functions to interpolate the knots.

n_knots [integer(1)]

Number of inner knots. To prevent weird behavior on the edges the inner knots are expanded by \(\mathrm{degree} - 1\) additional knots.

penalty [numeric(1)]

Positive numeric value to specify the penalty parameter. Setting the penalty to 0 ordinary B-splines are used for the fitting.

differences [integer(1)]

The number of differences which are penalized. A higher value leads to smoother curves.

Details

The data matrix of the source data is restricted to have just one column. The spline bases are created for this single feature. Multidimensional splines are not supported at the moment.

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_p_spline_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) y = sin(1:10) # Create new data object: data_source = InMemoryData$new(data_mat, "my_data_name") data_target = InMemoryData$new() # Create new linear base-learner: spline_factory = BaselearnerPSpline$new(data_source, data_target, list(degree = 3, n_knots = 4, penalty = 2, differences = 2)) # Get the transformed data: spline_factory$getData()
#> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 0.16666667 0.66666667 0.166666667 0.0000000000 0.0000000000 0.000000000 #> [2,] 0.01463192 0.44375857 0.513031550 0.0285779607 0.0000000000 0.000000000 #> [3,] 0.00000000 0.11705533 0.655006859 0.2277091907 0.0002286237 0.000000000 #> [4,] 0.00000000 0.00617284 0.370370370 0.5740740741 0.0493827160 0.000000000 #> [5,] 0.00000000 0.00000000 0.078417924 0.6227709191 0.2969821674 0.001828989 #> [6,] 0.00000000 0.00000000 0.001828989 0.2969821674 0.6227709191 0.078417924 #> [7,] 0.00000000 0.00000000 0.000000000 0.0493827160 0.5740740741 0.370370370 #> [8,] 0.00000000 0.00000000 0.000000000 0.0002286237 0.2277091907 0.655006859 #> [9,] 0.00000000 0.00000000 0.000000000 0.0000000000 0.0285779607 0.513031550 #> [10,] 0.00000000 0.00000000 0.000000000 0.0000000000 0.0000000000 0.166666667 #> [,7] [,8] #> [1,] 0.00000000 0.00000000 #> [2,] 0.00000000 0.00000000 #> [3,] 0.00000000 0.00000000 #> [4,] 0.00000000 0.00000000 #> [5,] 0.00000000 0.00000000 #> [6,] 0.00000000 0.00000000 #> [7,] 0.00617284 0.00000000 #> [8,] 0.11705533 0.00000000 #> [9,] 0.44375857 0.01463192 #> [10,] 0.66666667 0.16666667
# Summarize factory: spline_factory$summarizeFactory()
#> Spline factory of degree 3 #> - Name of the used data: my_data_name #> - Factory creates the following base-learner: spline_degree_3
# Transform data manually: spline_factory$transformData(data_mat)
#> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 0.16666667 0.66666667 0.166666667 0.0000000000 0.0000000000 0.000000000 #> [2,] 0.01463192 0.44375857 0.513031550 0.0285779607 0.0000000000 0.000000000 #> [3,] 0.00000000 0.11705533 0.655006859 0.2277091907 0.0002286237 0.000000000 #> [4,] 0.00000000 0.00617284 0.370370370 0.5740740741 0.0493827160 0.000000000 #> [5,] 0.00000000 0.00000000 0.078417924 0.6227709191 0.2969821674 0.001828989 #> [6,] 0.00000000 0.00000000 0.001828989 0.2969821674 0.6227709191 0.078417924 #> [7,] 0.00000000 0.00000000 0.000000000 0.0493827160 0.5740740741 0.370370370 #> [8,] 0.00000000 0.00000000 0.000000000 0.0002286237 0.2277091907 0.655006859 #> [9,] 0.00000000 0.00000000 0.000000000 0.0000000000 0.0285779607 0.513031550 #> [10,] 0.00000000 0.00000000 0.000000000 0.0000000000 0.0000000000 0.166666667 #> [,7] [,8] #> [1,] 0.00000000 0.00000000 #> [2,] 0.00000000 0.00000000 #> [3,] 0.00000000 0.00000000 #> [4,] 0.00000000 0.00000000 #> [5,] 0.00000000 0.00000000 #> [6,] 0.00000000 0.00000000 #> [7,] 0.00617284 0.00000000 #> [8,] 0.11705533 0.00000000 #> [9,] 0.44375857 0.01463192 #> [10,] 0.66666667 0.16666667