\HeaderA{classification}{General method for classification with various methods}{classification}
\keyword{multivariate}{classification}
\begin{Description}\relax
Most general function in the package, providing an interface
to perform variable selection, hyperparameter tuning and
classification in one step. Alternatively, the first two
steps can be performed separately and can then be plugged into
this function.

For S4 method information, s. \code{\LinkA{classification-methods}{classification.Rdash.methods}}.
\end{Description}
\begin{Usage}
\begin{verbatim}
classification(X, y, f, learningsets, genesel, genesellist = list(), nbgene, classifier, tuneres, tuninglist = list(), trace = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] Gene expression data. Can be one of the following:
\Itemize{
\item A \code{matrix}. Rows correspond to observations, columns to variables.
\item A \code{data.frame}, when \code{f} is \emph{not} missing (s. below).
\item An object of class \code{ExpressionSet}.}

\item[\code{y}] Class labels. Can be one of the following:
\Itemize{
\item A \code{numeric} vector.
\item A \code{factor}.
\item A \code{character} if \code{X} is an \code{ExpressionSet} that
specifies the phenotype variable.
\item \code{missing}, if \code{X} is a \code{data.frame} and a
proper formula \code{f} is provided.
}
\bold{WARNING}: The class labels will be re-coded to
range from \code{0} to \code{K-1}, where \code{K} is the
total number of different classes in the learning set.
\item[\code{f}] A two-sided formula, if \code{X} is a \code{data.frame}. The
left part correspond to class labels, the right to variables.
\item[\code{learningsets}] An object of class \code{\LinkA{learningsets}{learningsets}}. May
be missing, then the complete datasets is used as
learning set.
\item[\code{genesel}] Optional (but usually recommended) object of class
\code{\LinkA{genesel}{genesel}} containing variable importance
information for the argument \code{learningsets}
\item[\code{genesellist}] In the case that the argument \code{genesel} is missing,
this is an argument list passed to \code{\LinkA{GeneSelection}{GeneSelection}}.
If both \code{genesel} and \code{genesellist} are missing,
no variable selection is performed.
\item[\code{nbgene}] Number of best genes to be kept for classification, based
on either \code{genesel} or the call to \code{\LinkA{GeneSelection}{GeneSelection}}
using \code{genesellist}. In the case that both are missing,
this argument is not necessary.
\bold{note}:
\Itemize{
\item If the gene selection method has been one of
\code{"lasso", "elasticnet", "boosting"},
\code{nbgene} will be reset to \code{min(s, nbgene)}
where \code{s} is the number of nonzero coefficients.
\item if the gene selection scheme has been \code{"one-vs-all", "pairwise"}
for the multiclass case, there exist several rankings.
The top \code{nbgene} will be kept of \emph{each} of them,
so the number of effective used genes will sometimes be much
larger.
}

\item[\code{classifier}] Name of function ending with \code{CMA} indicating
the classifier to be used.
\item[\code{tuneres}] Analogous to the argument \code{genesel} - object of
class \code{\LinkA{tuningresult}{tuningresult}} containing information
about the best hyperparameter choice for the argument
\code{learningsets}.
\item[\code{tuninglist}] Analogous to the argument \code{genesellist}. In the
case that the argument \code{tuneres} is missing, this
in argument list passed to \code{\LinkA{tune}{tune}}.
If both \code{tuneres} and \code{tuninglist} are missing,
no variable selection is performed.
\bold{warning}: Note that if a user-defined hyperparameter
grid is passed, this will result in a list within a list:
\code{tuninglist = list(grids=list(argname = c())}, s. example.
\bold{warning}: Contrary to \code{\LinkA{tune}{tune}}, if
\code{tuninglist} is an empty list (default),
\emph{no} hyperparameter tuning
will be performed at all. To use pre-defined hyperparameter
grids, the argument is \code{tuninglist = list(grids = list())}.
\item[\code{trace}] Should progress be traced ? Default is \code{TRUE}.
\item[\code{...}] Further arguments passed to the function \code{classifier}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For details about hyperparameter tuning, consult \code{\LinkA{tune}{tune}}.
\end{Details}
\begin{Value}
A list of objects of class \code{\LinkA{cloutput}{cloutput}} and \code{\LinkA{clvarseloutput}{clvarseloutput}},
respectively; its length equals the number of different \code{learningsets}.
The single elements of the list can convenienly be combined using
the \code{\LinkA{join}{join}} function. The results can be analyzed and
evaluated by various measures using the method \code{\LinkA{evaluation}{evaluation}}.
\end{Value}
\begin{Author}\relax
Martin Slawski \email{martin.slawski@campus.lmu.de}

Anne-Laure Boulesteix \url{http://www.slcmsr.net/boulesteix}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{GeneSelection}{GeneSelection}}, \code{\LinkA{tune}{tune}}, \code{\LinkA{evaluation}{evaluation}},
\code{\LinkA{compBoostCMA}{compBoostCMA}}, \code{\LinkA{dldaCMA}{dldaCMA}}, \code{\LinkA{ElasticNetCMA}{ElasticNetCMA}},
\code{\LinkA{fdaCMA}{fdaCMA}}, \code{\LinkA{flexdaCMA}{flexdaCMA}}, \code{\LinkA{gbmCMA}{gbmCMA}},
\code{\LinkA{knnCMA}{knnCMA}}, \code{\LinkA{ldaCMA}{ldaCMA}}, \code{\LinkA{LassoCMA}{LassoCMA}},
\code{\LinkA{nnetCMA}{nnetCMA}}, \code{\LinkA{pknnCMA}{pknnCMA}}, \code{\LinkA{plrCMA}{plrCMA}},
\code{\LinkA{pls\_ldaCMA}{pls.Rul.ldaCMA}}, \code{\LinkA{pls\_lrCMA}{pls.Rul.lrCMA}}, \code{\LinkA{pls\_rfCMA}{pls.Rul.rfCMA}},
\code{\LinkA{pnnCMA}{pnnCMA}}, \code{\LinkA{qdaCMA}{qdaCMA}}, \code{\LinkA{rfCMA}{rfCMA}},
\code{\LinkA{scdaCMA}{scdaCMA}}, \code{\LinkA{shrinkldaCMA}{shrinkldaCMA}}, \code{\LinkA{svmCMA}{svmCMA}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
### a simple k-nearest neighbour example
### datasets
## Not run: 
plot(x)
data(golub)
golubY <- golub[,1]
golubX <- as.matrix(golub[,-1])
### learningsets
set.seed(111)
lset <- GenerateLearningsets(y=golubY, method = "CV", fold=5, strat =TRUE)
### 1. GeneSelection
selttest <- GeneSelection(golubX, golubY, learningsets = lset, method = "t.test")
### 2. tuning
tunek <- tune(golubX, golubY, learningsets = lset, genesel = selttest, nbgene = 20, classifier = knnCMA)
### 3. classification
knn1 <- classification(golubX, golubY, learningsets = lset, genesel = selttest,
                       tuneres = tunek, nbgene = 20, classifier = knnCMA)
### steps 1.-3. combined into one step:
knn2 <- classification(golubX, golubY, learningsets = lset,
                       genesellist = list(method  = "t.test"), classifier = knnCMA,
                       tuninglist = list(grids = list(k = c(1:8))), nbgene = 20)
### show and analyze results:
knnjoin <- join(knn2)
show(knn2)
eval <- evaluation(knn2, measure = "misclassification")
show(eval)
summary(eval)
boxplot(eval)
## End(Not run)
\end{ExampleCode}
\end{Examples}

