Learn R Programming

FastKRR (version 0.1.2)

error.krr: Compute Model Error for Kernel Ridge Regression Models

Description

Computes the model error for kernel ridge regression ("krr") objects. Returns the mean squared error (MSE) between the observed responses and the fitted values stored in the object.

Usage

# S3 method for krr
error(x, ...)

Value

A numeric value giving the mean squared error (MSE).

Arguments

x

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

...

Additional arguments (ignored).

Details

This method computes: $$\text{MSE} = \frac{1}{n} \sum_i (y_i - \hat{y}_i)^2$$ where y and fitted.values are stored in the "krr" object attributes.

See Also

summary.krr, plot.krr, predict.krr

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))

model = fastkrr(X, y, kernel = "gaussian", lambda = 0.001)
error(model)


Run the code above in your browser using DataLab