# condense: Condense training set for k-NN classifier In class: Functions for Classification

## Description

Condense training set for k-NN classifier

## Usage

 `1` ```condense(train, class, store, trace = TRUE) ```

## Arguments

 `train` matrix for training set `class` vector of classifications for test set `store` initial store set. Default one randomly chosen element of the set. `trace` logical. Trace iterations?

## Details

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.

## Value

Index vector of cases to be retained (the final store set).

## References

P. A. Devijver and J. Kittler (1982) Pattern Recognition. A Statistical Approach. Prentice-Hall, pp. 119–121.

Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

`reduce.nn`, `multiedit`

## Examples

 ```1 2 3 4 5 6 7``` ```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, , drop=FALSE], test, cl[keep]) keep2 <- reduce.nn(train, keep, cl) knn(train[keep2, , drop=FALSE], test, cl[keep2]) ```

### Example output

```[1] 65
[1] 32 65
[1] 13 32 65
[1] 13 32 65 74
[1] 13 32 44 65 74
[1] 13 32 44 48 65 74
[1] 13 32 44 48 61 65 74
[1] 13 32 44 48 61 65 70 74
[1] s s s s s s s s s s s s s s s s s s s s s s s s s c c v c c c c c v c c c c
[39] c c c c c c c c c c c c v v v v v v v v c v v v v v v v v v v v v v v v v
Levels: c s v
[1] s s s s s s s s s s s s s s s s s s s s s s s s s c c v c c c c c v c c c c
[39] c c c c c c c c c c c c v v v v v v v v c v v v v v v v v v v v v v v v v
Levels: c s v
```

class documentation built on Jan. 13, 2022, 9:07 a.m.