rec_predict: Evaluate the empirical reconstruction error for new data

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/main.R

Description

Evaluate the reconstruction error based on object with 'sKPCA' class or 'oKPCA' class.

Usage

1
  rec_predict(obj, tsdata)

Arguments

obj

an object with 'sKPCA' class or 'oKPCA' class.

tsdata

a matrix of newdata to be evaluted for reconstruction error (RE). If it is NULL, then the RE of training data is evaluated, default as NULL.

Value

return a numeric vector whose length is equal to the row of tsdata.

Note

nothing

Author(s)

Liu Wei

References

nothing.

See Also

nothing

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  library(kernlab)
  data(iris)
  set.seed(1)
  test <- sample(1:150,20)
  trdata <- iris[-test,-5]
  tsdata <- iris[test, -5]
  n <- nrow(trdata)
  kern <- rbfdot(sigma = 1e-2)
  ## evaluate reconstruction error for sKPCA and oKPCA
  ## centralized sKPCA
  skc <- sKPCA(trdata, d=2, m=30, kern =kern)
  rec_predict(skc, tsdata)

  ## centralized oKPCA
  okc <- oKPCA(trdata, d=2, kern=kern)
  rec_predict(okc, tsdata)

  ## non-centralized sKPCA
  sknc <- sKPCA(trdata, d=2, m=30, kern =kern, center=F)
  rec_predict(sknc, tsdata)
  ## non-centralized oKPCA
  oknc <- oKPCA(trdata, d=2, kern=kern, center=F)
  rec_predict(oknc, tsdata)

feiyoung/sKPCA documentation built on Nov. 12, 2020, 8:18 a.m.