BaselearnerCategoricalRidge: One-hot encoded base learner for a categorical feature

BaselearnerCategoricalRidgeR Documentation

One-hot encoded base learner for a categorical feature

Description

This base learner can be used to estimate effects of categorical features. The classes are included similar as in the linear model by using a one-hot encoded data matrix. Additionally, a Ridge penalty allows unbiased feature selection.

Arguments

data_source

CategoricalDataRaw
Data container of the raw categorical feature.

blearner_type

(character(1))
Type of the base learner (if not specified, blearner_type = "ridge" is used). The unique id of the base learner is defined by appending blearner_type to the feature name: paste0(data_source$getIdentifier(), "_", blearner_type).

df

(numeric(1))
Degrees of freedom of the base learner(s).

Format

S4 object.

Usage

BaselearnerCategoricalRidge$new(data_source, list(df))
BaselearnerCategoricalRidge$new(data_source, blearner_type, list(df))

Fields

This class doesn't contain public fields.

Methods

  • ⁠$summarizeFactory()⁠: ⁠() -> ()⁠

  • ⁠$transfromData(newdata)⁠: list(InMemoryData) -> matrix()

  • ⁠$getMeta()⁠: ⁠() -> list()⁠

Inherited methods from Baselearner

  • ⁠$getData()⁠: ⁠() -> matrix()⁠

  • ⁠$getDF()⁠: ⁠() -> integer()⁠

  • ⁠$getPenalty()⁠: ⁠() -> numeric()⁠

  • ⁠$getPenaltyMat()⁠: ⁠() -> matrix()⁠

  • ⁠$getFeatureName()⁠: ⁠() -> character()⁠

  • ⁠$getModelName()⁠: ⁠() -> character()⁠

  • ⁠$getBaselearnerId()⁠: ⁠() -> character()⁠

Examples

# Sample data:
x = sample(c("one","two"), 20, TRUE)
y = c(one = 0.8, two = -1.2)[x] + rnorm(20, 0, 0.2)
dat = data.frame(x, y)

# S4 API:
ds = CategoricalDataRaw$new(x, "cat")
bl = BaselearnerCategoricalRidge$new(ds, list(df = 1))

bl$getData()
bl$summarizeFactory()

bl$getData()
bl$summarizeFactory()
bl$transformData(list(ds))
bl$getBaselearnerId()

# R6 API:
cboost = Compboost$new(dat, "y")
cboost$addBaselearner("x", "binary", BaselearnerCategoricalRidge)
cboost$train(100, 0)
table(cboost$getSelectedBaselearner())
plotPEUni(cboost, "x", individual = FALSE)


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