Dear all, I've sent a mail last week already. I've been trying to get this predict function work, but somehow I keep on getting the same error. Read the help files, searched the internet, but I don't seem to get what I'm doing wrong.
Anybody who has experience with this function? It's contained in the package e1071. Thank you in advance On Thu, Feb 19, 2009 at 2:16 PM, joris meys <jorism...@gmail.com> wrote: > Dear all, > > I tried a simple naive Bayes classification on an artificial dataset, but I > have troubles getting the predict function to work with the type="class" > specification. With type= "raw", it works perfectly, but with type="class" I > get following error : > > Error in as.vector(x, mode) : invalid 'mode' argument > > Data : mixture.train is a training set with 100 points originating from 2 > multivariate gaussian distributions (class 0 and class 1), with X1 and X2 as > coordinates in a 2-dimensional space. Mixture.test is a grid going from -15 > to +15 in both dimensions. Stupid data, but it's just to test. > > Code : > Sigma <- matrix(c(10,3,3,2),2,2) > mixture.train <- cbind(mvrnorm(n=50, c(0, 2), Sigma),rep(0,50)) > mixture.train <- as.data.frame(rbind(mixture.train,cbind(mvrnorm(n=50, c(2, > 0), Sigma),rep(1,50)))) > names(mixture.train) <-c("X1","X2","Class") > X1 <- rep(seq(-15,15,by=1),31) > X2 <- rep(seq(-15,15,by=1),each = 31) > mixture.test <- data.frame(X1,X2) > > Bayes.res <- naiveBayes(Class ~ X1 + X2, data=mixture.train) > pred.bayes <-predict(Bayes.res, cbind(mixture.test$X1, > mixture.test$X2),type="class") > > Tried it also with pred.bayes <-predict(Bayes.res, > mixture.test,type="class"), but that gives the same effect. Is this a bug or > am I missing something? > > Kind regards > Joris Meys > University Ghent > > > [[alternative HTML version deleted]] ______________________________________________ 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.