PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Microsoft

Compute precision/recall from a flaky top-k API

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of binary classification evaluation metrics (precision and recall) and competency in handling unreliable API behavior for robust metric computation, testing both conceptual understanding and practical application.

  • medium
  • Microsoft
  • Software Engineering Fundamentals
  • Machine Learning Engineer

Compute precision/recall from a flaky top-k API

Company: Microsoft

Role: Machine Learning Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

You have 10 image files. Each file has a ground-truth label indicating whether it contains a dog. You can call an API like `searchDogs(k)` which is intended to return **k file IDs** that the system predicts are dogs (e.g., top-k results for the query "dog"). Tasks: 1) Write pseudocode to compute **precision** and **recall** of the API’s returned results with respect to the ground truth. 2) Follow-up: the API may behave unexpectedly (returns `None`, throws, returns fewer than k items, returns more than k items, returns duplicates, or returns unknown file IDs). How would you handle these cases so the metric computation is robust and well-defined?

Quick Answer: This question evaluates understanding of binary classification evaluation metrics (precision and recall) and competency in handling unreliable API behavior for robust metric computation, testing both conceptual understanding and practical application.

Related Interview Questions

  • Explain OOP design and API rollout - Microsoft (hard)
  • Explain a project deeply - Microsoft (medium)
  • Explain Python, Java, and Memory Management - Microsoft (medium)
  • Explain how browser authentication works with JWTs - Microsoft (hard)
  • Explain deadlock cases and how to prevent them - Microsoft (medium)
Microsoft logo
Microsoft
Feb 9, 2026, 12:00 AM
Machine Learning Engineer
Technical Screen
Software Engineering Fundamentals
3
0

You have 10 image files. Each file has a ground-truth label indicating whether it contains a dog.

You can call an API like searchDogs(k) which is intended to return k file IDs that the system predicts are dogs (e.g., top-k results for the query "dog").

Tasks:

  1. Write pseudocode to compute precision and recall of the API’s returned results with respect to the ground truth.
  2. Follow-up: the API may behave unexpectedly (returns None , throws, returns fewer than k items, returns more than k items, returns duplicates, or returns unknown file IDs). How would you handle these cases so the metric computation is robust and well-defined?

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Microsoft•More Machine Learning Engineer•Microsoft Machine Learning Engineer•Microsoft Software Engineering Fundamentals•Machine Learning Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.