How to Read a 3x3 Confusion Matrix

Hello All.

I have a 3x3 confusion matrix for three sentiment classes - positive, negative and neutral. The classification was done with Quanteda package.

# Train and test the model using the document feature matrix
reviewClassifier <- textmodel_nb(reviewCorpusdfmTrain, englishReviewsTrain$rating) # training

predicted_class <- predict(reviewClassifier, newdata = reviewCorpusdfmTest) # testing

tab_class <- table(englishReviewsTest$rating, predicted_class)

# Check performance of the classifier
confMat <- confusionMatrix(tab_class, mode = "everything")

confMat

Confusion Matrix and Statistics

          predicted_class
           Negative Neutral Positive
  Negative       27       4        5
  Neutral         2       0        2
  Positive        8       5      153

How can I stop R or Quanteda from sorting the classes in alphabetical order? I will prefer it to be Positive, Negative, Neutral.

Also, I can understand three outcomes clearly - True Positive, True Negative and True Neutral. How do I read or interpret the other six outcomes?

Thank you.

The off diagonal entries are misclassified. 2 means for two observations actual category was neutral but predicted class using the classifier was negative.
To answer your other question try using the dnn argument found in the confusionMatrix documentation:
https://www.rdocumentation.org/packages/caret/versions/3.45/topics/confusionMatrix

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.