Description Usage Arguments Details Value Author(s) See Also Examples

Function for simple knn classification.

1 2 3 4 5 6 7 8 9 10 | ```
sknn(x, ...)
## Default S3 method:
sknn(x, grouping, kn = 3, gamma=0, ...)
## S3 method for class 'data.frame'
sknn(x, ...)
## S3 method for class 'matrix'
sknn(x, grouping, ..., subset, na.action = na.fail)
## S3 method for class 'formula'
sknn(formula, data = NULL, ..., subset, na.action = na.fail)
``` |

`x` |
matrix or data frame containing the explanatory variables
(required, if |

`grouping` |
factor specifying the class for each observation
(required, if |

`formula` |
formula of the form |

`data` |
Data frame from which variables specified in |

`kn` |
Number of nearest neighbours to use. |

`gamma` |
gamma parameter for rbf in knn. If |

`subset` |
An index vector specifying the cases to be used in the training sample. (Note: If given, this argument must be named.) |

`na.action` |
specify the action to be taken if |

`...` |
currently unused |

If `gamma>0`

an gaussian like density is used to weight the classes of the `kn`

nearest neighbors.
`weight=exp(-gamma*distance)`

. This is similar to an rbf kernel.
If the distances are large it may be useful to `scale`

the data first.

A list containing the function call.

Karsten Luebke, [email protected]

1 2 3 |

```
Loading required package: MASS
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.