10. Confusion Matrix as Sets

Medium

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

  • true positive: ABA \cap B
  • false positive: ABcA \cap B^c
  • false negative: AcBA^c \cap B
  • true negative: AcBcA^c \cap B^c

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

solve({1,2,3}, {2,3,4}, {1,2,3,4,5})
->  {"tp": 2, "fp": 1, "fn": 1, "tn": 1}

Sign in to write and run your own code.

Implement solve(...)