Which Corner Is the Miss?

Machine Learning in CodeMedium+10 XP+10

Which Corner Is the Miss?

Real labels are often words, not 0 and 1. A clinic's model labels scans "malignant" or "benign". A bank's model labels payments "fraud" or "ok".

Task: write misses_and_false_alarms(y_true, y_pred, positive) and return [misses, false_alarms].

  • positive is the label you are trying to find, such as "fraud".
  • A miss (false negative) is a row whose real label is positive but whose predicted label is not.
  • A false alarm (false positive) is a row whose real label is not positive but whose predicted label is.
  • Across both lists there are exactly two different labels, and positive is one of them.

Return both counts as whole numbers.

Examples

y_true = ['ok', 'fraud', 'ok', 'fraud', 'fraud', 'ok']
y_pred = ['ok', 'ok', 'fraud', 'fraud', 'ok', 'ok']
positive = 'fraud'
returns [2, 1]
y_true = ['ham', 'spam', 'spam', 'ham', 'ham']
y_pred = ['spam', 'spam', 'ham', 'ham', 'spam']
positive = 'spam'
returns [1, 2]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run