predict.ASDA {accSDA} | R Documentation |
Predict method for sparse discriminant analysis
Description
Predicted values based on fit from the function ASDA
. This
function is used to classify new observations based on their explanatory variables/features.
Usage
## S3 method for class 'ASDA'
predict(object, newdata = NULL, ...)
Arguments
object |
Object of class ASDA. This object is returned from the function |
newdata |
A matrix of new observations to classify. |
... |
Arguments passed to |
Value
A list with components:
class
The classification (a factor)
posterior
posterior probabilities for the classes
x
the scores
Note
The input matrix newdata should be normalized w.r.t. the normalization of the training data
See Also
Examples
# Prepare training and test set
train <- c(1:40,51:90,101:140)
Xtrain <- iris[train,1:4]
nX <- normalize(Xtrain)
Xtrain <- nX$Xc
Ytrain <- iris[train,5]
Xtest <- iris[-train,1:4]
Xtest <- normalizetest(Xtest,nX)
Ytest <- iris[-train,5]
# Define parameters for SDAD
Om <- diag(4)+0.1*matrix(1,4,4) #elNet coef mat
gam <- 0.01
lam <- 0.01
method <- "SDAD"
q <- 2
control <- list(PGsteps = 100,
PGtol = c(1e-5,1e-5),
mu = 1,
maxits = 100,
tol = 1e-3,
quiet = FALSE)
# Run the algorithm
res <- ASDA(Xt = Xtrain,
Yt = Ytrain,
Om = Om,
gam = gam ,
lam = lam,
q = q,
method = method,
control = control)
# Do the predictions on the test set
preds <- predict(object = res, newdata = Xtest)
[Package accSDA version 1.1.3 Index]