Table of Hits and Misses
truth holds real labels and guess predicted ones, both from 0 to k - 1, and every label appears in truth. Return the confusion matrix: a k by k table in which the entry in row i, column j counts the cases whose real label is i and whose predicted label is j.
Example 1
truth [0,0,1,1,1]
guess [0,1,1,1,0]
returns [[1,1],[1,2]]
Of the two real 0s, one was called 0 and one 1. Of the three real 1s, one was called 0 and two 1.
Constraints
2 <= k <= 4len(truth) <= 60
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More scikit-learn problems
- Vote of the NeighborsEasy
- Yes or NoEasy
- Average Over Five FoldsMedium
- Best Number of NeighborsMedium
- Centers of the GroupsMedium
- Column That Matters MostMedium
- How Well It RanksMedium
- No PeekingMedium