[R] Cross validation for Naive Bayes and Bayes Networks

Marco Scutari marco.scutari at gmail.com
Mon Apr 15 15:45:17 CEST 2013


Hi Guilherme,

On Sun, Apr 14, 2013 at 11:48 PM, Guilherme Ferraz de Arruda
<guiep at yahoo.com.br> wrote:
> Hi,
> I need to classify, using Naive Bayes and Bayes Networks,  and estimate
> their performance using cross validation.
> How can I do this?
> I tried the bnlearn package for Bayes Networks, althought I need to get
> more indexes, not only the error rate (precision, sensitivity, ...).

You can do that using the object returned by bn.cv(), because it
contains the predicted values and the indexes of the corresponding
observations in the original data, for each fold. It's just a matter
to reassemble observed and predicted class labels and compute your
metrics.

> I also tried the *e1071* package, but I could not find a way to do
> cross-validation.

You might be able to trick the tune() function to do it, but I am not sure.

Marco

-- 
Marco Scutari, Ph.D.
Research Associate, Genetics Institute (UGI)
University College London (UCL), United Kingdom



More information about the R-help mailing list