k-Nearest Neighbour Classification
ipredknn.RdArguments
- formula
a formula of the form
lhs ~ rhswherelhsis the response variable andrhsa set of predictors.- data
optional data frame containing the variables in the model formula.
- subset
optional vector specifying a subset of observations to be used.
- na.action
function which indicates what should happen when the data contain
NAs.- k
number of neighbours considered, defaults to 5.
- ...
additional parameters.
Value
An object of class ipredknn. See predict.ipredknn.
Examples
library("mlbench")
learn <- as.data.frame(mlbench.twonorm(300))
mypredict.knn <- function(object, newdata)
predict.ipredknn(object, newdata, type="class")
errorest(classes ~., data=learn, model=ipredknn,
predict=mypredict.knn)
#>
#> Call:
#> errorest.data.frame(formula = classes ~ ., data = learn, model = ipredknn,
#> predict = mypredict.knn)
#>
#> 10-fold cross-validation estimator of misclassification error
#>
#> Misclassification error: 0.02
#>