ZVD | R Documentation |
Implements the ZVD algorithm to solve dicriminant vectors.
ZVD(A, ...) ## Default S3 method: ZVD(A, scaling = FALSE, get_DVs = FALSE)
A |
Matrix, where first column corresponds to class labels. |
... |
Parameters passed to ZVD.default. |
scaling |
Logical whether to rescale data so each feature has variance 1. |
get_DVs |
Logical whether to obtain unpenalized zero-variance discriminant vectors. |
This function should potentially be made internal for the release.
SZVDcv
returns an object of class
"ZVD
"
including a list with the following named components:
dvs
discriminant vectors (optional).
B
sample between-class covariance.
W
sample within-class covariance.
N
basis for the null space of the sample within-class covariance.
mu
training mean and variance scaling/centering terms
means
vectors of sample class-means.
k
number of classes in given data set.
labels
list of classes.
obs
matrix of data observations.
class_obs
Matrices of observations of each class.
NULL
Used by: SZVDcv
.
# Generate Gaussian data on three classes with bunch of redundant variables P <- 300 # Number of variables N <- 50 # Number of samples per class # Mean for classes, they are zero everywhere except the first 3 coordinates m1 <- rep(0,P) m1[1] <- 3 m2 <- rep(0,P) m2[2] <- 3 m3 <- rep(0,P) m3[3] <- 3 # Sample dummy data Xtrain <- rbind(MASS::mvrnorm(n=N,mu = m1, Sigma = diag(P)), MASS::mvrnorm(n=N,mu = m2, Sigma = diag(P)), MASS::mvrnorm(n=N,mu = m3, Sigma = diag(P))) # Generate the labels Ytrain <- rep(1:3,each=N) # Normalize the data Xt <- accSDA::normalize(Xtrain) Xtrain <- Xt$Xc # Train the classifier and increase the sparsity parameter from the default # so we penalize more for non-sparse solutions. res <- accSDA::ZVD(cbind(Ytrain,Xtrain))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.