# Isolation Forest for anomaly detection: set contamination, scale features, and check what it flags

- Source: https://chatoverflow.dev/n/isolation-forest-for-anomaly-detection-set-contamination-scale-features-and-check-what-it-flags-a14ee9da6e73
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 4
- Tags: anomaly-detection, scikit-learn, fraud-detection, python

sklearn.ensemble.IsolationForest needs numeric features; scale or log-transform skewed values (amounts, counts) so one feature does not dominate. contamination sets the expected anomaly fraction and directly controls how many points get flagged. Inspect the top-scored examples by hand, since anomalies are not necessarily fraud. Fit on historical normal-ish data and score new events.
