boostLinear: Wrapper to boost linear models for each feature.

View source: R/boost_linear.R

boostLinearR Documentation

Wrapper to boost linear models for each feature.

Description

This wrapper function automatically initializes the model by adding all numerical features as linear base-learner. Categorical features are dummy encoded and inserted using another linear base-learners without intercept. The function boostLinear does also train the model.

The returned object is an object of the Compboost class. This object can be used for further analyses (see ?Compboost for details).

Usage

boostLinear(
  data,
  target,
  optimizer = NULL,
  loss = NULL,
  learning_rate = 0.05,
  iterations = 100,
  trace = -1,
  intercept = TRUE,
  data_source = InMemoryData,
  df_cat = 2,
  oob_fraction = NULL,
  stop_args = NULL
)

Arguments

data

(data.frame)
A data frame containing the data.

target

(character(1) | ResponseRegr | ResponseBinaryClassif)
Character value containing the target variable or response object. Note that the loss must match the data type of the target.

optimizer

(OptimizerCoordinateDescent | OptimizerCoordinateDescentLineSearch | OptimizerAGBM | OptimizerCosineAnnealing)
An initialized S4 optimizer object (requires to call Optimizer*.new(..). See the respective help page for further information.

loss

(LossQuadratic | LossBinomial | LossHuber | LossAbsolute | LossQuantile)
An initialized S4 loss object (requires to call ⁠Loss*$new(...)⁠). See the respective help page for further information.

learning_rate

(numeric(1))
Learning rate to shrink the parameter in each step.

iterations

(integer(1))
Number of iterations that are trained. If iterations == 0, the untrained object is returned. This can be useful if other base learners (e.g. an interaction via a tensor base learner) are added.

trace

(integer(1))
Integer indicating how often a trace should be printed. Specifying trace = 10, then every 10th iteration is printed. If no trace should be printed set trace = 0. Default is -1 which means that in total 40 iterations are printed.

intercept

(logical(1))
Internally used by BaselearnerPolynomial. This logical value indicates if each feature should get an intercept or not (default is TRUE).

data_source

(⁠Data*⁠)
Uninitialized ⁠Data*⁠ object which is used to store the data. At the moment just in memory training is supported.

df_cat

(numeric(1))
Degrees of freedom of the categorical base-learner.

oob_fraction

(numeric(1))
Fraction of how much data are used to track the out of bag risk.

stop_args

(list(2))
List containing two elements patience and eps_for_break which can be set to use early stopping on the left out data from setting oob_fraction. If ! is.null(stop_args), early stopping is triggered.

Value

A model of the Compboost class. This model is an R6 object which can be used for retraining, predicting, plotting, and anything described in ?Compboost.

Examples

mod = boostLinear(data = iris, target = "Sepal.Length", loss = LossQuadratic$new(),
  oob_fraction = 0.3)
mod$getBaselearnerNames()
mod$getEstimatedCoef()
table(mod$getSelectedBaselearner())
mod$predict()

schalkdaniel/compboost documentation built on April 15, 2023, 9:03 p.m.