-3

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.

2 Answers2

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