Multi-Label Classification Metrics

easy
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 2. Everything before it counts as cleared.

In multi-label problems (tagging a support ticket as both "billing" and "urgent"), each sample has a set of labels. Implement metrics for binary indicator matrices Y_true and Y_pred of shape (samples, labels):

  • hamming_loss: the fraction of individual label slots that are wrong
  • subset_accuracy: the fraction of samples where the whole row is exactly right
  • micro_f1: F1 over all TP/FP/FN summed across labels
  • macro_f1: the mean of per-label F1 (a label with no TP, FP or FN counts as F1 = 1.0)
  • jaccard_samples: the mean over samples of |true ∩ pred| / |true ∪ pred|, where two empty sets score 1.0
#metrics#multi-label#classification2 visible + 2 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Multi-Label Classification Metrics · TechGradify