confusionmatrix.RdA function to compute the confusion matrix of two classification vectors. It can be useful for evaluating discriminant analysis or other classification systems.
confusionmatrix(obs, predict)
| obs | a vector containing the observed classes. |
|---|---|
| predict | a vector with the same length of |
A square matrix containing the number of objects in each class,
observed (rows) and predicted (columns). Diagonal elements
refers to agreement of obs and predict.
Anderson Rodrigo da Silva <anderson.agro@hotmail.com>
aer, lda
data(iris) da <- lda(Species ~ ., data = iris) pred <- predict(da, dimen = 1) confusionmatrix(iris$Species, pred$class)#> new setosa new versicolor new virginica #> setosa 50 0 0 #> versicolor 0 48 2 #> virginica 0 0 50# End (not run)