62. Confusion Matrix as Sets

Medium

A confusion matrix is four set intersections. With AA the predicted positives and BB the actual positives:

  • true positive: A∩BA \cap B
  • false positive: A∩BcA \cap B^c
  • false negative: Ac∩BA^c \cap B
  • true negative: Ac∩BcA^c \cap B^c

Return a dict of the four counts under keys "tp", "fp", "fn", "tn".

Input

predicted_positive = {1, 2, 3}
actual_positive = {2, 3, 4}
sample_space = {1, 2, 3, 4, 5}

Output

{'tp': 2, 'fp': 1, 'fn': 1, 'tn': 1}
Implement solve(...)