Search code examples
rclassificationnaivebayes

How to cross validate a Naive Bayes classifier?


I use e1071 for naive classification

function

naiveBayes(x=, y=, )

I want to use cvTools for cross-validation

cvFit(....)

how could I write this, the documentation of cvFit is really hard to understand for me

typeof(naiveBayes) is 'closure'

Solution

  • I think it is much better to start using caret package. e.g. here's part of the code I am currently working on:

        library('caret')
    
        train_control <- trainControl(method="cv", number=10)
    
        #create model
        fit <- train(trainData[, -classIndex], trainData[, classIndex], method = "nb",trControl=train_control)