Learn R Programming

Rdimtools (version 0.3.2)

do.klde: Kernel Local Discriminant Embedding

Description

Kernel Local Discriminant Embedding (KLDE) is a variant of Local Discriminant Embedding in that it aims to preserve inter- and intra-class neighborhood information in a nonlinear manner using kernel trick. Note that the combination of kernel matrix and its eigendecomposition often suffers from lacking numerical rank. For such case, our algorithm returns a warning message and algorithm stops working any further due to its innate limitations of constructing weight matrix.

Usage

do.klde(X, label, ndim = 2, t = 1, numk = max(ceiling(nrow(X)/10), 2),
  preprocess = c("center", "scale", "cscale", "decorrelate", "whiten"),
  ktype = c("gaussian", 1), kcentering = TRUE)

Arguments

X

an \((n\times p)\) matrix or data frame whose rows are observations.

label

a length-\(n\) vector of data class labels.

ndim

an integer-valued target dimension.

t

kernel bandwidth in \((0,\infty)\).

numk

the number of neighboring points for k-nn graph construction.

preprocess

an additional option for preprocessing the data. Default is "center". See also aux.preprocess for more details.

ktype

a vector containing name of a kernel and corresponding parameters. See also aux.kernelcov for complete description of Kernel Trick.

kcentering

a logical; TRUE to use centered Kernel matrix, FALSE otherwise.

Value

a named list containing

Y

an \((n\times ndim)\) matrix whose rows are embedded observations.

trfinfo

a list containing information for out-of-sample prediction.

References

hwann-tzong_chen_local_2005Rdimtools

Examples

Run this code
# NOT RUN {
## generate data of 2 types with clear difference
diff = 5
dt1  = aux.gensamples(n=123)-diff;
dt2  = aux.gensamples(n=123)+diff;

## merge the data and create a label correspondingly
Y      = rbind(dt1,dt2)
label  = c(rep(1,123), rep(2,123))

## try different neighborhood size
out1 <- do.klde(Y, label, kcentering=TRUE, numk=5)
out2 <- do.klde(Y, label, numk=10)
out3 <- do.klde(Y, label, numk=25)

## visualize
par(mfrow=c(1,3))
plot(out1$Y[,1], out1$Y[,2], main="k=5")
plot(out2$Y[,1], out2$Y[,2], main="k=10")
plot(out3$Y[,1], out3$Y[,2], main="k=25")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab