How do I create a confusion matrix without any packages? I want to be able to see the logic of creating one. This can be any language or pseudo-code.
Asked
Active
Viewed 261 times
-3
-
take a look at http://www.dataschool.io/simple-guide-to-confusion-matrix-terminology/ – Ali Rokni Jul 18 '16 at 15:30
2 Answers
0
Technically, a confusion matrix is just a regular matrix.
Just compute the intersection sizes and then label the rows and columns as desired.

Has QUIT--Anony-Mousse
- 76,138
- 12
- 138
- 194
0
Well an option(maybe not the best in performance but great to understand the concept is this one which was the first one i implemented:
true_positives = 0;
true_negatives = 0;
false_negatives = 0;
false_positives = 0;
for i in range(0,np.size(predictions)):
if predictions[i]==1 and real_values[i]==1:
true_positives+=1;
if predictions[i]==0 and real_values[i]==0:
true_negatives+=1;
if predictions[i]==0 and real_values[i]==1:
false_negatives+=1;
if predictions[i]==1 and real_values[i]==0:
false_positives+=1;

Luis Leal
- 3,388
- 5
- 26
- 49