Compute and plot a precision–recall curve

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.

Quick Answer: 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.

|Home/Machine Learning/Microsoft
Microsoft logo
Microsoft
Jan 17, 2026, 12:00 AM
easyData ScientistTechnical ScreenMachine Learning
8
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.

Loading comments...