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?
How to Calculate a Confusion Matrix 1 First, you need to test dataset with its expected outcome values. 2 Predict all the rows in the test dataset. 3 Calculate the expected predictions and outcomes:
Iris Dataset is considered as the Hello World for data science. It contains five columns namely – Petal Length, Petal Width, Sepal Length, Sepal Width, and Species Type. Iris is a flowering plant, the researchers have measured various features of the different iris flowers and recorded them digitally.
Iris is a flowering plant, the researchers have measured various features of the different iris flowers and recorded them digitally. Note: This dataset can be downloaded from here. You can download the Iris.csv file from the above link.
Available with Spatial Analyst license. Computes a confusion matrix with errors of omission and commission and derives a kappa index of agreement and an overall accuracy between the classified map and the reference data. This tool uses the outputs from the Create Accuracy Assessment Points tool or the Update Accuracy Assessment Points tool.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With