Learn R Programming

Rdimtools (version 1.0.4)

do.mmc: Maximum Margin Criterion

Description

Maximum Margin Criterion (MMC) is a linear supervised dimension reduction method that maximizes average margin between classes. The cost function is defined as $$trace(S_b - S_w)$$ where \(S_b\) is an overall variance of class mean vectors, and \(S_w\) refers to spread of every class. Note that Principal Component Analysis (PCA) maximizes total scatter, \(S_t = S_b + S_w\).

Usage

do.mmc(
  X,
  label,
  ndim = 2,
  preprocess = c("center", "scale", "cscale", "decorrelate", "whiten")
)

Arguments

X

an \((n\times p)\) matrix or data frame whose rows are observations and columns represent independent variables.

label

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

ndim

an integer-valued target dimension.

preprocess

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

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.

projection

a \((p\times ndim)\) whose columns are basis for projection.

References

li_efficient_2006Rdimtools

Examples

Run this code
# NOT RUN {
## generate 3 different groups of data X and label vector
x1 = matrix(rnorm(4*10), nrow=10)-20
x2 = matrix(rnorm(4*10), nrow=10)
x3 = matrix(rnorm(4*10), nrow=10)+20
X     = rbind(x1, x2, x3)
label = rep(1:3, each=10)

## perform MVP with different preprocessings
out1 = do.mmc(X, label, ndim=2)
out2 = do.mmc(X, label, ndim=2, preprocess="decorrelate")

## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
plot(out1$Y, main="MMC::centering")
plot(out2$Y, main="MMC::decorrelating")
par(opar)

# }

Run the code above in your browser using DataLab