Confusion matrix cells

Write codeEasy10 minMeta and Google style

Your task

Your team ships a spam filter and the eval dashboard needs the four confusion-matrix cells. Given two equal-length lists of binary labels, y_true and y_pred (1 = spam, 0 = not spam), return the list [tp, fp, fn, tn] where tp counts pairs with true 1 and predicted 1, fp counts true 0 predicted 1, fn counts true 1 predicted 0, and tn counts true 0 predicted 0. Example: y_true = [1, 0, 1, 1, 0], y_pred = [1, 1, 0, 1, 0] gives [2, 1, 1, 1].

Examples

confusion_cells(y_true: list[int], y_pred: list[int]) -> list[int]
Example 1
Inputconfusion_cells([1, 0, 1, 1, 0], [1, 1, 0, 1, 0])
Output[2, 1, 1, 1]