liveBook · Manning

Scikit-learn

As explained in Outlier Detection in Python

scikit-learn is an open-source Python machine-learning library providing estimators, preprocessing utilities, model-selection tools, and related functionality.

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

How Outlier Detection in Python covers it

How deep it goes
Explains four detectors, their API outputs, preprocessing requirements, and comparative use, but does not detail their internal algorithms.
Examples
Uses Isolation Forest, Local Outlier Factor, one-class Support Vector Machine, Elliptic Envelope, make_classification(), and make_blobs().
What it assumes
Assumes Python machine-learning familiarity and requires numeric inputs, with encoding for categorical columns and scaling for distance-based detectors.
What you can do after
Apply it via scikit-learn to prepare tabular data, run multiple outlier detectors, and inspect scores and inlier or outlier labels.
How it connects
Connects outlier detection with preprocessing, classification, regression, clustering, Isolation Forest, Local Outlier Factor, and synthetic data.

Also explained in

Compare how 5 books explain scikit-learn →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.