sknn(x, ...)
"sknn"(x, grouping, kn = 3, gamma=0, ...)
"sknn"(x, ...)
"sknn"(x, grouping, ..., subset, na.action = na.fail)
"sknn"(formula, data = NULL, ..., subset, na.action = na.fail)formula is not given).formula is not given).groups ~ x1 + x2 + ....
That is, the response is the grouping factor and the right hand side specifies the (non-factor) discriminators.formula are preferentially to be taken.gamma=0 ordinary knn classification is used.NAs are
found. The default action is for the procedure to fail. An
alternative is na.omit, which leads to rejection of cases with
missing values on any required variable. (Note: If given, this
argument must be named.) 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.
predict.sknn, knndata(iris)
x <- sknn(Species ~ ., data = iris)
x <- sknn(Species ~ ., gamma = 4, data = iris)
Run the code above in your browser using DataLab