
Hello,

We have a system which creates thousands of regression/classification models and in cases where we have only one input variable  NaiveBayes throws an error. Maybe I am mistaken and I shouldn't expect to have a model with only one input variable.

We use R version 2.6.0 (2007-10-03). We use caret (v4.1.19), but have tested similar code with klaR (v.0.5.8), because caret relies on NaiveBayes implementation from klaR. I get different error messages from caret than from klaR so I will provide the code for caret usage and klaR usage.

Here is the code which uses the iris dataset.

> library(klaR);
Loading required package: MASS
> X<-iris["Sepal.Length"];
> Y<-iris["Species"];
> mnX<-as.matrix (X);
> mnY<-as.matrix (Y);
> cY<-factor(mnY);
> d <- data.frame (cbind(mnX,cY));
> m<-NaiveBayes(cY~mnX, data=d);
> predict(m);
Error in as.vector(x, mode) : invalid argument 'mode'
> library(caret);
Loading required package: lattice
> mCaret<-train(mnX,cY,method="nb",trControl = trainControl(method = "cv", number = 10));
Loading required package: class
Fitting: usekernel=TRUE
Fitting: usekernel=FALSE
> predicted <- predict(mCaret, newdata=mnX);
Error in 1:nrow(newdata) : NA/NaN argument
>

We use caret to call NaiveBayes and we don't have any error messages in cases where the number of input variables is greater than 1.

Cheers
DK

_________________________________________________________________
[[elided Hotmail spam]]

	[[alternative HTML version deleted]]


