Katkat

Compute and plot a precision–recall curve

MicrosoftData Scientist · Technical Screen

Last updated

This question evaluates understanding of binary classification evaluation metrics—precision, recall, precision–recall curves, and related summaries like Average Precision/AUPRC—within the Machine Learning domain and is relevant for Data Scientist roles.

Precision–Recall (PR) curve coding / evaluation

You are given a binary classifier’s outputs on a dataset:

  • y_true: array of true labels in ({0,1})
  • y_score: array of predicted scores/probabilities (higher means more likely positive)

Tasks

  1. Define precision and recall.
  2. Describe how to compute the precision–recall curve by sweeping a decision threshold over y_score.
  3. Implement (in pseudocode or Python) a function that returns PR curve points:
  • Output arrays: thresholds, precision, recall
  1. Mention at least two edge cases/pitfalls (e.g., ties in scores, no predicted positives at a threshold, extreme class imbalance).

Optional: Explain how to compute Average Precision / AUPRC and what the baseline means.