What does the contamination parameter control in detectors like Isolation Forest, and what happens if you set it wrong?

Quick Overview

Asks what the contamination setting does in outlier detectors such as Isolation Forest and what goes wrong when its value does not match reality. Tests how well you understand the parts of an anomaly detector, how a mis-set parameter shows up in its errors, and how to pick a value when the outlier rate is unknown.

What does the contamination parameter control in detectors like Isolation Forest, and what happens if you set it wrong?

Role: Data Scientist

Category: Statistics & Math

Difficulty: medium

Interview Round: Other

What does the `contamination` parameter control in detectors like Isolation Forest, and what happens if you set it wrong? ```hint Score versus label An outlier detector produces two things: a continuous anomaly score and a yes/no label. Ask which of the two this parameter touches. ``` ### What a Strong Answer Covers - What the parameter sets. - What it does and does not change in the fitted model. - The effect of setting it too high or too low on the detector's errors. - How to choose the value, or the threshold itself, when the true outlier rate is unknown. ### Follow-up Questions - You have a small labeled sample of anomalies. How would you use it to choose a threshold? - What does `contamination="auto"` do in scikit-learn's Isolation Forest? - If you refit the detector every day with the same `contamination`, what kind of change can you no longer detect? - How does `nu` in a One-Class SVM differ from `contamination`?

Overview: Asks what the contamination setting does in outlier detectors such as Isolation Forest and what goes wrong when its value does not match reality. Tests how well you understand the parts of an anomaly detector, how a mis-set parameter shows up in its errors, and how to pick a value when the outlier rate is unknown.

General logo
General
Nov 24, 2026
mediumData ScientistOtherStatistics & Math
0
0

What does the contamination parameter control in detectors like Isolation Forest, and what happens if you set it wrong?

What a Strong Answer Covers Guidance

  • What the parameter sets.
  • What it does and does not change in the fitted model.
  • The effect of setting it too high or too low on the detector's errors.
  • How to choose the value, or the threshold itself, when the true outlier rate is unknown.

Follow-up Questions Guidance

  • You have a small labeled sample of anomalies. How would you use it to choose a threshold?
  • What does contamination="auto" do in scikit-learn's Isolation Forest?
  • If you refit the detector every day with the same contamination , what kind of change can you no longer detect?
  • How does nu in a One-Class SVM differ from contamination ?