\Header{condense}{Condense training set for k-NN classifier}
\keyword{classif}{condense}
\begin{Description}\relax
Condense training set for k-NN classifier\end{Description}
\begin{Usage}
\begin{verbatim}
condense(train, class, store, trace=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{train}] matrix for training set

\item[\code{class}] vector of classifications for test set

\item[\code{store}] initial store set. Default one randomly chosen element of the set.

\item[\code{trace}] logical. Trace iterations?

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The store set is used to 1-NN classify the rest, and misclassified
patterns are added to the store set. The whole set is checked until
no additions occur.\end{Details}
\begin{Value}
index vector of cases to be retained (the final store set).\end{Value}
\begin{References}\relax
P. A. Devijver and J. Kittler (1982)
\emph{Pattern Recognition. A Statistical Approach.}
Prentice-Hall, pp. 119--121.\end{References}
\begin{SeeAlso}\relax
\code{\Link{reduce.nn}}, \code{\Link{multiedit}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(iris3)
train <- rbind(iris3[1:25,,1],iris3[1:25,,2],iris3[1:25,,3])
test <- rbind(iris3[26:50,,1],iris3[26:50,,2],iris3[26:50,,3])
cl <- factor(c(rep("s",25),rep("c",25), rep("v",25)))
keep <- condense(train, cl)
knn(train[keep,], test, cl[keep])
keep2 <- reduce.nn(train, keep, cl)
knn(train[keep2,], test, cl[keep2])
\end{ExampleCode}
\end{Examples}

