BaselearnerTensor | R Documentation |
This class combines base learners. The base learner is defined by a data matrix calculated as row-wise tensor product of the two data matrices given in the base learners to combine.
blearner1 |
( |
blearner2 |
( |
blearner_type |
( |
anisotrop |
( |
S4 object.
BaselearnerTensor$new(blearner1, blearner2, blearner_type) BaselearnerTensor$new(blearner1, blearner2, blearner_type, anisotrop)
This class doesn't contain public fields.
$summarizeFactory()
: () -> ()
$transfromData(newdata)
: list(InMemoryData) -> matrix()
$getMeta()
: () -> list()
$getData()
: () -> matrix()
$getDF()
: () -> integer()
$getPenalty()
: () -> numeric()
$getPenaltyMat()
: () -> matrix()
$getFeatureName()
: () -> character()
$getModelName()
: () -> character()
$getBaselearnerId()
: () -> character()
# Sample data:
x1 = runif(100, 0, 10)
x2 = runif(100, 0, 10)
y = sin(x1) * cos(x2) + rnorm(100, 0, 0.2)
dat = data.frame(x1, x2, y)
# S4 wrapper
# Create new data object, a matrix is required as input:
ds1 = InMemoryData$new(cbind(x1), "x1")
ds2 = InMemoryData$new(cbind(x2), "x2")
# Create new linear base learner factory:
bl1 = BaselearnerPSpline$new(ds1, "sp", list(n_knots = 10, df = 5))
bl2 = BaselearnerPSpline$new(ds2, "sp", list(n_knots = 10, df = 5))
tensor = BaselearnerTensor$new(bl1, bl2, "row_tensor")
# Get the transformed data:
dim(tensor$getData())
# Get full meta data such as penalty term or matrix as well as knots:
str(tensor$getMeta())
# Transform "new data":
newdata = list(InMemoryData$new(cbind(runif(5)), "x1"),
InMemoryData$new(cbind(runif(5)), "x2"))
str(tensor$transformData(newdata))
# R6 wrapper
cboost = Compboost$new(dat, "y")
cboost$addTensor("x1", "x2", df = 5)
cboost$train(50, 0)
table(cboost$getSelectedBaselearner())
plotTensor(cboost, "x1_x2_tensor")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.