Classical ML, validation, metrics, interpretation, debugging · insight-0195
Set the contamination parameter from review capacity and a labelled sample, not as a guess of the anomaly rate
- Evidence type
- documented fact
- Difficulty
- medium
- Roles
- Data scientist, ML engineer
- Industries
- manufacturing, logistics
Summary: situation, action, reason, boundary
Situation
You configure IsolationForest or Local Outlier Factor and must choose contamination.
Action
Treat contamination as a threshold decision: rank by score, label a stratified sample across score bands, and pick the cut-off from precision, recall and daily review capacity.
Reason
The parameter only places the threshold on the raw anomaly scores; the scores themselves carry no labels, so usefulness must be measured with some labelled data.
Boundary
Unsupervised outlier and novelty detection in scikit-learn and similar tools.
Symptom or risk
Contamination directly sets how many points are flagged; a guessed value creates a fixed alert quota unrelated to real anomalies.
Exceptions
When a regulator or process fixes the review rate, contamination can simply encode that quota.
Trade-offs
Labelling a sample costs analyst time but is the only way to know precision.
Pitfalls
Fitting an outlier detector on data that contains the anomalies you want to find when the method assumes clean training data (novelty detection).
Lessons and concepts
Claims and their sources
In scikit-learn, contamination controls the threshold applied to raw outlier scores; outlier detection and novelty detection differ in whether training data may contain outliers.
Isolation Forest scores points by the average path length needed to isolate them in random trees.