How can density estimation be used to score anomalies?

Quick Overview

Asks how a density model fitted to normal data can be used to score anomalies. Tests the negative log-density score, threshold choices, the trade-offs between Gaussian, mixture, kernel and flow models, and failure modes such as contaminated training data, high dimensions and clusters of varying density.

How can density estimation be used to score anomalies?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How can density estimation be used to score anomalies? ```hint What to score If you knew the true density of normal data, which quantity of a new point would tell you how surprising it is, and why work with its logarithm? ``` ```hint Where it breaks Picture normal data with two separate modes, and then data with hundreds of dimensions. ``` ### What a Strong Answer Covers - The scoring rule: fit a density to mostly normal data and score points by how unlikely they are under it - How to turn scores into flags with a threshold - Model choices (single Gaussian, mixture, kernel density, normalizing flow) and when each fits - Failure modes such as contaminated training data, smoothing choices, high dimensions and regions of different density ### Follow-up Questions - How would you choose the number of mixture components or the kernel bandwidth when you have no labeled anomalies? - Why can a deep generative model assign higher likelihood to out-of-distribution inputs than to its own training data? - How would you handle categorical features alongside continuous ones? - How would you keep the threshold meaningful as normal behavior drifts?

Overview: Asks how a density model fitted to normal data can be used to score anomalies. Tests the negative log-density score, threshold choices, the trade-offs between Gaussian, mixture, kernel and flow models, and failure modes such as contaminated training data, high dimensions and clusters of varying density.

PracHub logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

How can density estimation be used to score anomalies?

What a Strong Answer Covers Guidance

  • The scoring rule: fit a density to mostly normal data and score points by how unlikely they are under it
  • How to turn scores into flags with a threshold
  • Model choices (single Gaussian, mixture, kernel density, normalizing flow) and when each fits
  • Failure modes such as contaminated training data, smoothing choices, high dimensions and regions of different density

Follow-up Questions Guidance

  • How would you choose the number of mixture components or the kernel bandwidth when you have no labeled anomalies?
  • Why can a deep generative model assign higher likelihood to out-of-distribution inputs than to its own training data?
  • How would you handle categorical features alongside continuous ones?
  • How would you keep the threshold meaningful as normal behavior drifts?