Example is given below. One thought is to remove D and E from actual data and the corresponding prediction from predicted data set. I would like to use ! notation. I A list of the row numbers of data to be removed would be helpful. Can someone help? Thanks.
# Load the caret package
library(caret)
# Create some example data
actual <- factor(c("A", "D", "C", "A", "E", "C"))
predicted <- factor(c("A", "B", "C", "B", "C", "A"))
# Create the confusion matrix
confusionMatrix(actual, predicted)
#print the confusion matrix
print(confusion_matrix)
Error in confusionMatrix.default(actual, predicted) :
the data cannot have more levels than the reference
# Create the confusion matrix
confusionMatrix(predicted,actual)
#print the confusion matrix
print(confusion_matrix)
Error in confusionMatrix.default(predicted, actual) :
The data contain levels not found in the data.