build_fm: Build a feature map on new data

View source: R/build_fm.R

build_fmR Documentation

Build a feature map on new data

Description

Feature maps provide a set of covariates in a transformed space. The build_fm() function creates these covariates based on an object that specifies the feature map and a provided dataset.

Usage

build_fm(kfm_fit, new_data, ...)

## S3 method for class 'kfm_exact'
build_fm(kfm_fit, new_data, ...)

## S3 method for class 'kfm_nystrom'
build_fm(kfm_fit, new_data, ...)

Arguments

kfm_fit

An object from a function in the kfm_* family, such as kfm_nystrom().

new_data

The data to generate features from.

...

Additional arguments for methods.

Value

A matrix of covariates in the feature space, with the same number of rows as new_data. If new_data is a mild_df object, build_fm() will also return the columns containing 'bag_label', 'bag_name', 'instance_name'.

Methods (by class)

  • kfm_exact: Method for kfm_exact class.

  • kfm_nystrom: Method for kfm_nystrom class.

Author(s)

Sean Kent

See Also

  • kfm_nystrom() fit a Nystrom kernel feature map approximation.

  • kfm_exact() create an exact kernel feature map.

Examples

df <- data.frame(
  X1 = c(2,   3,   4,   5,   6, 7, 8),
  X2 = c(1, 1.2, 1.3, 1.4, 1.1, 7, 1),
  X3 = rnorm(7)
)

fit <- kfm_nystrom(df, m = 7, r = 6, kernel = "radial", sigma = 0.05)
fm <- build_fm(fit, df)

fit <- kfm_exact(kernel = "polynomial", degree = 2, const = 1)
fm <- build_fm(fit, df)


mildsvm documentation built on July 14, 2022, 9:08 a.m.