BaselearnerCategoricalBinary: Base learner to encode one single class of a categorical...

BaselearnerCategoricalBinaryR Documentation

Base learner to encode one single class of a categorical feature

Description

This class create a one-column one-hot encoded data matrix with ones at x == class_name and zero otherwise.

Arguments

data_source

CategoricalDataRaw
The raw data object. Must be an object generated by CategoricalDataRaw.

class_name

(character(1))
The class for which a binary vector is created as data representation.

blearner_type

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

Format

S4 object.

Usage

BaselearnerCategoricalBinary$new(data_source, class_name)
BaselearnerCategoricalBinary$new(data_source, class_name, blearner_type)

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 = BaselearnerCategoricalBinary$new(ds, "one")

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

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

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