Given the following:
library(rpart.plot)
iris <- read.csv("iris.csv")
my.control <- rpart.control(cp = 0, minsplit=5, xval=10)
iris.rpart <- rpart(Species ~ ., iris[,-6], method='class',
control=my.control, parms=list(split='gini'))
iris.rpart2 <- prune(iris.rpart, cp=0.094)
table(Original = iris$Species,
Predicted = predict(iris.rpart2, type='class'))
This yields a 3x3 matrix of original and predicted values.
Question: Using this data, how do I now create a 2x2 confusion matrix of true/false labels from the original dataset on one axis, and true/false labels from the algorithm on the other axis? This would be a sort of aggregate confusion matrix.
Desired Output:
True labels:
disagree agree
Algorithm labels:
disagree A B
agree C D
df
with two columns, true membership and predicted membership, you can simply dotable(df)
$\endgroup$