On 22.03.2012 03:24, palanski wrote:
Hi!

I'm using GLM, LDA and NaiveBayes for binomial classification. My training
set is 70 rows long with 32 features, and my test set is 30 rows long with
32 features.

Using Naive Bayes, I can train a model, and then predict the test set with
it like so:

ass4q1.dLDA = lda(ass4q1.trainSet[,1]~ass4q1.trainSet[,2:3])
table(predict(ass4q1.dNB, ass4q1.testSetDF[,2:3]), ass4q1.testSetDF[,1])


However, when the same is done for LDA or GLM, suddenly it tells me that the
number of rows doesn't match and doesn't predict my test data. The error for
GLM, as an example, is:

Error in table(predict(ass4q1.dGLM, ass4q1.testSetDF[, 2:3]),
ass4q1.testSetDF[,  :
   all arguments must have the same length
In addition: Warning message:
'newdata' had 30 rows but variable(s) found have 70 rows
>

What am I missing?

A correct formula describing the model with separate variables with the data.frame passed to the data argument of the lda() function.
A reproducible example is missing, hence this is just a guess.

Uwe Ligges




--
View this message in context: 
http://r.789695.n4.nabble.com/predict-for-LDA-and-GLM-tp4494381p4494381.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

______________________________________________
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.

Reply via email to