I am getting an error while using naiveBayes() method in R. I am passing the the as.matrix(train_matrix)as first parameter and as.factor(train_data$subcategory) to the naiveBayes function.
I am getting below error :
model <- naiveBayes(as.matrix(trainmatrix),as.factor(traindata$subCategory)); Error in tapply(var, y, mean, na.rm = TRUE) : arguments must have same length
Can anyone help me on this?
model <- naiveBayes(as.matrix(trainmatrix),as.factor(traindata$subCategory));
Where trainMatrix is term document matrix, traindata - is the data on which in need the model to get trained on and subCategory is the class (different levels).
Am i doing it the right way?