Learn R Programming

dprep (version 2.1)

crossval: Cross validation estimation of the misclassification error

Description

Computation of the misclassification error for the LDA, KNN and rpart classifiers by cross validation

Usage

crossval(data, nparts = 10, method = c("lda", "knn", "rpart"), 
kvec = 5, repet)

Arguments

data
The name of the dataset
nparts
The number of folds in which the dataset is divided. By default nparts=10.
method
The name of the classifier to be used: LDA,KNN, Rpart.
kvec
The number of nearest neighbors to be used for the KNN classifier.
repet
The number of repetitions

Value

  • Returns the mean misclassification crossvalidation error of the classifier obtained on a given number of repetitions

See Also

cv10log, cv10mlp

Examples

Run this code
#------10-fold crossvalidation error using the LDA classifier---
data(bupa)
crossval(bupa,method="lda",repet=10)
#------5-fold crossvalidation error using the knn classifier---
data(colon)
crossval(colon,nparts=5,method="knn",kvec=3,repet=5)

Run the code above in your browser using DataLab