Re: [R] NAIVE BAYES with 10-fold cross validation
thx for your help, i checked the caret package out and the tuning works. but i can't find a way to make a contingency table in order to see the classification result. e.g. like: table(outcome NaiveBayes, mydata$code) Is there something like that? Julia Original-Nachricht Datum: Tue, 30 Oct 2007 17:03:49 -0400 Von: Kuhn, Max [EMAIL PROTECTED] An: Julia Kröpfl [EMAIL PROTECTED], r-help@r-project.org Betreff: RE: [R] NAIVE BAYES with 10-fold cross validation am trying to implement the code of the e1071 package for naive bayes, but it doens't really work, any ideas?? am very glad about any help!! need a naive bayes with 10-fold cross validation: The caret package will do this. Use fit - train( x, y, method = nb, trControl = trainControl(method = cv, number = 10)) (there is no formula interface yet). It will use the naïve Bayes implementation in klaR. Unless you specify otherwise, it will train naïve Bayes models with and without using kernel density estimation (but you can change that). The object fit$finalModel will contain the model fit that is cv optimal. For example: fit - train( +iris[,-5], iris$Species, nb, +trControl = trainControl(method = cv, number = 10)) Iter 1 Values: TRUE Loading required package: MASS Loading required package: class Iter 2 Values: FALSE fit Call: train.default(x = iris[, -5], y = iris$Species, method = nb, trControl = trainControl(method = cv, number = 10)) 150 samples 4 predictors summary of cross-validation (10 fold) sample sizes: 135, 135, 135, 135, 135, 135, ... cv resampled training results across tuning parameters: usekernel Accuracy Kappa Accuracy SD Kappa SD Optimal FALSE 0.953 0.93 0.0706 0.106 TRUE 0.96 0.94 0.0562 0.0843* Accuracy was used to select the optimal model Max -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julia Kröpfl Sent: Tuesday, October 30, 2007 4:46 PM To: r-help@r-project.org Subject: [R] NAIVE BAYES with 10-fold cross validation hi there!! i am trying to implement the code of the e1071 package for naive bayes, but it doens't really work, any ideas?? i am very glad about any help!! i need a naive bayes with 10-fold cross validation: code: library(e1071) model - naiveBayes(code ~ ., mydata) tune.control - tune.control(random = FALSE, nrepeat = 1, repeat.aggregate = min, sampling = c(cross), sampling.aggregate = mean, cross = 10, best.model = TRUE, performances = TRUE) pred - predict(model, mydata[,-12], type=class) tune(naiveBayes, code~., mydata, predict.fun=pred, tune.control) thx for your help! cheers, julia -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NAIVE BAYES with 10-fold cross validation
Julia, i checked the caret package out and the tuning works. but i can't find a way to make a contingency table in order to see the classification result. You should read the vignettes for the package at: http://cran.r-project.org/src/contrib/Descriptions/caret.html these have the details for caret. There are many other methods. Typing help.search(confusion) yields four different implementations on my system. Looking at your email, you need to read something about basic predict methods. Please read ?predict.NaiveBayes Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NAIVE BAYES with 10-fold cross validation
am trying to implement the code of the e1071 package for naive bayes, but it doens't really work, any ideas?? am very glad about any help!! need a naive bayes with 10-fold cross validation: The caret package will do this. Use fit - train( x, y, method = nb, trControl = trainControl(method = cv, number = 10)) (there is no formula interface yet). It will use the naïve Bayes implementation in klaR. Unless you specify otherwise, it will train naïve Bayes models with and without using kernel density estimation (but you can change that). The object fit$finalModel will contain the model fit that is cv optimal. For example: fit - train( +iris[,-5], iris$Species, nb, +trControl = trainControl(method = cv, number = 10)) Iter 1 Values: TRUE Loading required package: MASS Loading required package: class Iter 2 Values: FALSE fit Call: train.default(x = iris[, -5], y = iris$Species, method = nb, trControl = trainControl(method = cv, number = 10)) 150 samples 4 predictors summary of cross-validation (10 fold) sample sizes: 135, 135, 135, 135, 135, 135, ... cv resampled training results across tuning parameters: usekernel Accuracy Kappa Accuracy SD Kappa SD Optimal FALSE 0.953 0.93 0.0706 0.106 TRUE 0.96 0.94 0.0562 0.0843* Accuracy was used to select the optimal model Max -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julia Kröpfl Sent: Tuesday, October 30, 2007 4:46 PM To: r-help@r-project.org Subject: [R] NAIVE BAYES with 10-fold cross validation hi there!! i am trying to implement the code of the e1071 package for naive bayes, but it doens't really work, any ideas?? i am very glad about any help!! i need a naive bayes with 10-fold cross validation: code: library(e1071) model - naiveBayes(code ~ ., mydata) tune.control - tune.control(random = FALSE, nrepeat = 1, repeat.aggregate = min, sampling = c(cross), sampling.aggregate = mean, cross = 10, best.model = TRUE, performances = TRUE) pred - predict(model, mydata[,-12], type=class) tune(naiveBayes, code~., mydata, predict.fun=pred, tune.control) thx for your help! cheers, julia -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.