n cross validation to determine an estimate

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ;svd" [8] "call" > table(predict(diab.ld,diab[,1:5])$class,diab[,6]) 123 1 26 0 0 2 5 31 3 3 1 5 73 . . . . . "N" . Cross-validation To determine an estimate of the misclassification rate that is not biased, we use cross-validation. Usually for LDA we use leave-one out cross validation (n fold) X 1 ∪ X2 ∪ X 3 . . . ∪ X n . . . . . . conf <- function(class.predict,class){ confusion=table(class.predict,class) return(confusion) } library(class) train <- rbind(iris3[1:25,,1], iris3[1:25,,2], iris3[1:25,,3]) test <- rbind(iris3[26:50,,1], iris3[26:50,,2], iris3[26:50,,3]) cl <- factor(c(rep("s",25), rep("c",25), rep("v",25))) knn(train, test, cl, k = 3, prob=TRUE) iris.knncv2=knn.cv(train, cl, k = 2, prob = TRUE) iris.knncv4=knn.cv(train, cl, k = 4, prob = TRUE) iris.knncv8=knn.cv(train, cl, k = 8, prob = TRUE) iris.knncv12=knn.cv(train, cl, k = 12, prob = TRUE) table(cl,iris.knncv2) iris.knncv2 cl csv c 47 0 3 s 0 50 0 v 5 0 45 > table(cl,iris.knncv8) iris.knncv8 . . . . . . cl csv c 47 0 3 s 0 50 0 v 2 0 48 > table(cl,iris.knncv12) iris.knncv12 cl csv c 47 0 3 s 0 50 0 v 3 0 47 classifier <- IBk(class ~ ., data = iris, control = Weka_control(K = 1 > evaluate_Weka_classifier(classifier, numFolds = 10) === 10 Fold Cross Validation === === Summary === Correctly Classified Instances 144 96 % Incorrectly Classifie...
View Full Document

This document was uploaded on 02/16/2014 for the course STATISTICS 3026 at Columbia.

Ask a homework question - tutors are online