Compute and plot a precision–recall curve

Read the full interview experience this question came from →

Quick Overview

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.

Compute and plot a precision–recall curve

Company: Microsoft

Role: Data Scientist

Category: Machine Learning

Difficulty: easy

Interview Round: Technical Screen

## 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` 4. 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.

Overview: 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.

Read the full Microsoft Data Scientist interview experience this question came from

Microsoft logo
Microsoft
Jan 17, 2026
easyData ScientistTechnical ScreenMachine Learning
10
0

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}\{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
  4. 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.