| train.kknn {kknn} | R Documentation |
Training of kknn method via leave-one-out crossvalidation.
train.kknn(formula, data, kmax = 11, distance = 2, kernel = NULL,
ykernel = NULL, contrasts = c('unordered' = "contr.dummy",
ordered = "contr.ordinal"), ...)
formula |
A formula object. |
data |
Matrix or data frame. |
kmax |
Maximum number of k. |
distance |
Parameter of Minkowski distance. |
kernel |
Kernel to use. Possible choices are "rectangular" (which is standard unweighted knn), "triangular", "epanechnikov" (or beta(2,2)), "biweight" (or beta(3,3)), "triweight" (or beta(4,4)), "cos", "inv" and "gaussian". |
ykernel |
|
contrasts |
A vector containing the 'unordered' and 'ordered' contrasts to use. |
... |
Further arguments passed to or from other methods. |
train.kknn returns a list-object of class train.kknn including
the components
MISCLASS |
Matrix of misclassification errors. |
MEAN.ABS |
Matrix of mean absolute errors. |
MEAN.SQU |
Matrix of mean squared errors. |
fitted.values |
List of predictions for all combinations of kernel and k. |
best.parameters |
List containing the best parameter value for kernel and k. |
response |
Type of response variable, one of continuous, nominal or ordinal. |
distance |
Parameter of Minkowski distance. |
call |
The matched call. |
terms |
The 'terms' object used. |
Klaus P. Schliep K.P.Schliep@massey.ac.nz
Hechenbichler K. and Schliep K.P. (2004) Weighted k-Nearest-Neighbor Techniques and Ordinal Classification, Discussion Paper 399, SFB 386, Ludwig-Maximilians University Munich (http://www.stat.uni-muenchen.de/sfb386/papers/dsp/paper399.ps)
Hechenbichler K. (2005) Ensemble-Techniken und ordinale Klassifikation, PhD-thesis
kknn and simulation
library(kknn)
data(miete)
(train.con <- train.kknn(nmqm ~ wfl + bjkat + zh, data = miete,
kmax = 25, kernel = c("rectangular", "triangular", "epanechnikov",
"gaussian", "rank")))
plot(train.con)
(train.ord <- train.kknn(wflkat ~ nm + bjkat + zh, miete, kmax = 25,
kernel = c("rectangular", "triangular", "epanechnikov", "gaussian",
"rank")))
plot(train.ord)
(train.nom <- train.kknn(zh ~ wfl + bjkat + nmqm, miete, kmax = 25,
kernel = c("rectangular", "triangular", "epanechnikov", "gaussian",
"rank")))
plot(train.nom)
data(glass)
glass <- glass[,-1]
(fit.glass1 <- train.kknn(Type ~ ., glass, kmax = 15, kernel =
c("triangular", "rectangular", "epanechnikov"), distance = 1))
(fit.glass2 <- train.kknn(Type ~ ., glass, kmax = 15, kernel =
c("triangular", "rectangular", "epanechnikov"), distance = 2))
plot(fit.glass1)
plot(fit.glass2)