scikit-learn is a Python machine-learning library for tabular data. It supplies estimators for classification, regression, clustering, and outlier detection, alongside preprocessing, evaluation, and postprocessing tools. section 5.1
For outlier detection, scikit-learn provides Isolation Forest, Local Outlier Factor, one-class Support Vector Machine, and Elliptic Envelope. These numeric detectors share a standard API and return scores plus labels: −1 for outliers and 1 for inliers. section 5.0 section 5.1
Prepare data and interpret detector results deliberately:
- Encode categorical columns because the outlier detectors operate on numeric data. section 5.1
- Scale features for every listed detector except Isolation Forest, since the others use distances between points. section 5.1
- Try several detectors rather than treating one algorithm as universally reliable; different detectors can identify different outliers. section 5.0
- Use library implementations for tested behavior and optimization, while retaining enough understanding to write custom code when necessary. section 5.0
Synthetic detector experiments
Use make_classification() or make_blobs() to create initial toy data, then manually insert outliers before testing detectors. These generators create normal data rather than realistic anomalies, so realistic synthetic data remains preferable for tuning and evaluating a working system. section 11.2.1




