Compute ROC AUC From Raw Scores for Defender Alert Triage

Last updated: November 29, 2026

Quick Overview

Given binary labels and model scores for Microsoft Defender alerts (1 = true incident), write a function that computes ROC AUC without a library, handling tied scores correctly, and explain what the number means.

Microsoft
Machine Learning
Machine Learning Engineer
Microsoft
November 29, 2026
Machine Learning Engineer
Technical Screen
Machine Learning
Medium

0

0

0 solved


Given binary labels and model scores for Microsoft Defender alerts (1 = true incident), write a function that computes ROC AUC without a library, handling tied scores correctly, and explain what the number means.

Microsoft ML screens often mix a small coding task into a metrics discussion. Security teams triaging Defender alerts rank them by score, so the interviewer wants to see you know AUC is a ranking metric and can compute it efficiently with ties.

What the Interviewer Expects
  • State AUC as the probability a random positive outranks a random negative
  • Implement the rank-sum (Mann Whitney) formulation in O(n log n)
  • Give ties half credit via average ranks
  • Raise an error or define behavior when only one class is present
  • Discuss when AUC is the wrong metric for triage (PR AUC, precision at top k)
Key Topics to Cover
ROC AUC
Mann Whitney U
ranking metrics
ties
class imbalance
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • How would you compute AUC on a dataset too large to sort on one machine?
  • Why can AUC look great while analysts still drown in false alerts?
  • How would you compute a confidence interval for this AUC?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

Input: lists labels (0/1) and scores (floats) of equal length. Output: ROC AUC. Tied scores between a positive and a negative count as half a correct ordering. If there are no positives or no nega...

Approach

AUC equals P(s+>s−)+12P(s+=s−)P(s^+ > s^-) + \tfrac12 P(s^+ = s^-). Comparing all pairs is O(n+n−)O(n_+ n_-). Instead sort by score, assign 1-based ranks (average rank within a tie group), and use the rank-sum identity: $A...


Submit Your Answer
Markdown supported