Last chance! 50% off unlimited learning
Sale ends in
Applies SZVD heuristic for sparse zero-variance discriminant analysis to given training set.
SZVD(train, ...)# S3 method for default
SZVD(
train,
gamma,
D,
penalty = TRUE,
scaling = TRUE,
tol = list(abs = 1e-04, rel = 1e-04),
maxits = 2000,
beta = 1,
quiet = TRUE,
...
)
SZVD
returns an object of class
"SZVD
" including a list
with the following named components:
DVs
Discriminant vectors.
its
Number of iterations required to find DVs.
pen_scal
Weights used in reweighted l1-penalty.
N
Basis for the null-space of the sample within-class covariance.
means
Training class-means.
mus
Training meand and variance scaling/centering terms.
w0
unpenalized zero-variance discriminants (initial solutions) plus B and W, etc.
NULL
Data matrix where first column is the response class.
Parameters passed to SZVD.default.
Set of regularization parameters controlling l1-penalty.
dictionary/basis matrix.
Controls whether to apply reweighting of l1-penalty (using sigma = within-class std devs).
Logical indicating whether to scale data such that each feature has variance 1.
Stopping tolerances for ADMM algorithm, must include tol$rel and tol$abs.
Maximum number of iterations used in the ADMM algorithm.
penalty term controlling the splitting constraint.
Print intermediate outpur or not.
This function will currently solve as a standalone function in accSDA for time comparison. A wrapper function like ASDA will be created to use the functionality of plots and such. Maybe call it ASZDA. For that purpose the individual ZVD function will need to be implemented.
Used by: SZVDcv
.
set.seed(123)
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::SZVD(cbind(Ytrain,Xtrain),beta=2.5,
maxits=1000,tol = list(abs = 1e-04, rel = 1e-04))
Run the code above in your browser using DataLab