Skip to contents

Calculate the error using only the first n dimensions of the embedded data. error_fun can either be one of c("rmse", "mae") to calculate the root mean square error or the mean absolute error respectively, or a function that takes to equally sized vectors as input and returns a single number as output.

Usage

# S4 method for dimRedResult
reconstruction_error(object, n = seq_len(ndims(object)), error_fun = "rmse")

Arguments

object

of class dimRedResult

n

a positive integer or vector of integers <= ndims(object)

error_fun

a function or string indicating an error function, if indication a function it must take to matrices of the same size and return a scalar.

Value

a vector of number with the same length as n with the

Author

Guido Kraemer

Examples

if (FALSE) {
ir <- loadDataSet("Iris")
ir.drr <- embed(ir, "DRR", ndim = ndims(ir))
ir.pca <- embed(ir, "PCA", ndim = ndims(ir))

rmse <- data.frame(
  rmse_drr = reconstruction_error(ir.drr),
  rmse_pca = reconstruction_error(ir.pca)
)

matplot(rmse, type = "l")
plot(ir)
plot(ir.drr)
plot(ir.pca)
}