liveBook · Manning

Elliptic envelope

As explained in Outlier Detection in Python

EllipticEnvelope is a scikit-learn estimator that detects outliers by fitting a robust covariance-based elliptical model to the data.

An elliptic envelope detects outliers by fitting a robust, covariance-based elliptical model around a dominant data cluster. It measures each point with distances that account for feature variances and correlations, rather than treating dimensions independently. The estimator uses a robust covariance estimate, specifically MCD, and Mahalanobis distances to flag points substantially outside the fitted ellipse. section 5.5 section 5.5.2

Use an elliptic envelope when:

  • The observations form one well-defined cluster rather than several distinct clusters. section 5.5.2 section 5.8
  • Feature correlations and unequal variances make plain Euclidean distance misleading. section 5.5
  • The features are reasonably close to Gaussian, especially when working with a carefully selected subset. section 5.5.2
  • Avoid treating its predictions as universally reliable: higher dimensions make its distributional assumptions harder to satisfy, and multiple detectors may be useful. section 5.0 section 5.5.2

scikit-learn implementation

Fit EllipticEnvelope on selected features, call predict, and map its output of -1 and 1 to anomaly and inlier labels for visualization. A two-feature OpenML dataset shows the method flagging fringe points around a single cluster. On the KDD Cup data, the detector achieved an AUROC of 0.77 in the reported comparison. section 5.5.2

Figure 5.6 The middle pane is an example of using Euclidean distance from the center of a dataset to measure the outlierness of datapoints. Here, point A is a stronger outlier than point B but is the same distance from the center using Euclidean distance. The right pane is an example using distances based on fitting an ellipse to the data and provides more meaningful distance measures, allowing us to consider A farther from the center than B.

Compare Euclidean distance with ellipse-based distance: correlated, skewed data can make a point appear more anomalous under the fitted shape than under distance from the center alone. section 5.5

How Outlier Detection in Python covers it

How deep it goes
Explains covariance-aware distance, MCD, Mahalanobis distance, implementation, examples, evaluation, and high-dimensional limitations.
Examples
Uses skewed two-dimensional points, KDD Cup data, and an OpenML dataset plotted with scikit-learn and seaborn.
What it assumes
Assumes familiarity with tabular features, covariance, Gaussian distributions, and basic scikit-learn estimator workflows.
What you can do after
Apply it via scikit-learn to predict outliers, inspect Mahalanobis-based scores, visualize flagged points, and compare detection quality.
How it connects
Connects robust covariance estimation and Mahalanobis distance with Isolation Forest, LOF, OCSVM, and Gaussian mixture models.

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.