Reputation: 2283
I have the following confusion matrix (received from summary of model summary (model)
):
=== Confusion Matrix ===
a b c <-- classified as
344 12 4 | a = 1
28 43 4 | b = 2
9 1 32 | c = 3
I would like to extract into df1 just the matrix content as followed:
a b c
344 12 4
28 43 4
9 1 32
We should take into consideration that the size of the matrix can be changed. I need a general solution. Is there a way to extract it straightforward from the model and from txt file as well?
Upvotes: 0
Views: 891
Reputation: 2283
My source model is from J48 model:
> class(summary (model) )
[1] "Weka_classifier_evaluation"
In order to get the confusion matrix:
> summary (model)$confusionMatrix
predicted
1 2 3
1 344 12 4
2 28 43 4
3 9 1 32
Upvotes: 1