Question

Data set: Iris How to compute the confusion matrix on the data set for an LDA (Linear Discriminant Analysis) model?

>iris.lda = lda(Species ~ . , data = iris)

>table(predict(iris.lda, type="class"), iris$Species)
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
Was it helpful?

Solution

Try this one

library(MASS)
iris.lda <- lda(Species ~ . , data = iris)
table(predict(iris.lda, type="class")$class, iris$Species)


          setosa versicolor virginica
  setosa         50          0         0
  versicolor      0         48         1
  virginica       0          2        49
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top