Back to questions
JuniorTheoryCommon
What does this program print?
from sklearn.metrics import confusion_matrix
y_true = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]
y_pred = [1, 1, 1, 0, 0, 1, 0, 0, 0, 0]
cm = confusion_matrix(y_true, y_pred)
print(cm.ravel().tolist())[4, 1, 2, 3]
- Expecting
[3, 2, 1, 4], the textbook layout with the positive class first: scikit-learn puts class0first, soravel()gives TN, FP, FN, TP. - Expecting the columns to be the true classes: rows are the true classes and columns the predicted ones, so the one false positive sits at
cm[0, 1].
- Which cell of this matrix holds the false negatives, and how many are there?
- How would the output change if
labels=[1, 0]were passed toconfusion_matrix?