Lets say i have the following two sets of categories and a variable containing the target names:
spam = ["blue", "white", "blue", "yellow", "red"]
flagged = ["blue", "white", "yellow", "blue", "red"]
target_names = ["blue", "white", "yellow", "red"]
When i use the confusion_matrix function as following, this is the result:
from sklearn.metrics import confusion_matrix
confusion_matrix(spam, flagged, labels=target_names)
[[1 0 1 0]
[0 1 0 0]
[1 0 0 0]
[0 0 0 1]]
However, when i give the parameter labels
the information that i only want the metrics from 'blue', i get this result:
confusion_matrix(spam, flagged, labels=["blue"])
array([[1]])
With only one number i cannot calculate accuracy, precision, recall etc. What am i doing wrong here? filling in yellow, white or blue will result into a 0, 1 and 1.