如何在Iris数据集上计算混淆矩阵?

时间:2012-11-14 09:15:28

标签: r lda

数据集:虹膜 如何计算LDA(线性判别分析)模型数据集的混淆矩阵?

>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?

1 个答案:

答案 0 :(得分:6)

试试这个

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