[R] confusion matrix error

romzero romzero at yahoo.it
Thu Jun 2 19:32:13 CEST 2011


Hi,
this is my R-script
I need to make a confusion matrix
but the last row return me an error

require(mixOmics)
require(SDMTools)

file <- "C:\\data.txt"
d <- read.table(file, header=T, row.names = NULL)

X <- as.matrix(d[,2:11])
Y <- as.factor(d[,1])

i <- 1 
samp <- sample(1:3, nrow(X), replace = TRUE) # Creation of a list of the
same size as X

test <- which(samp == i) # Search which column in samp has a value of 1
train <- setdiff(1:nrow(X), test) # Keeping the column that are not in test

#PLS-DA
plsda.train <- plsda(X[train, ], Y[train], ncomp = 10)
test.predict <- predict(plsda.train, X[test, ], method = "class.dist")

confusion.matrix(test.predict, Y[-train])

Error in confusion.matrix(test.predict, Y[-train]) : 
  this requires the same number of observed & predicted values

I have no idea why it don't work

Thank you for help

--
View this message in context: http://r.789695.n4.nabble.com/confusion-matrix-error-tp3568913p3568913.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list