Learn R Programming

FastKRR (version 0.1.2)

coef.krr: Coef method for fitted Kernel Ridge Regression models

Description

Displays the main coefficient information from a fitted Kernel Ridge Regression (KRR) model, including the original function call and the first few estimated coefficients. The type of coefficient reported depends on the kernel approximation method: for opt = "exact", "nystrom", or "pivoted", the coefficients represent \(\alpha\); for opt = "rff", they represent the coefficient (\(\beta\)).

Usage

# S3 method for krr
coef(object, ...)

Value

A human-readable summary of the fitted KRR model to the console.

Arguments

object

An S3 object of class krr, typically returned by fastkrr.

...

Additional arguments (currently ignored).

See Also

fastkrr

Examples

Run this code
# Data setting
set.seed(1)
lambda = 1e-4
d = 1
n = 50
rho = 1
X = matrix(runif(n*d, 0, 1), nrow = n, ncol = d)
y = as.vector(sin(2*pi*rowMeans(X)^3) + rnorm(n, 0, 0.1))

# Example: exact
model = fastkrr(X, y,
                kernel = "gaussian", opt = "exact",
                rho = rho, lambda = 1e-4)
class(model)

coef(model)

Run the code above in your browser using DataLab