liveBook · Manning

Local outlier

As explained in Outlier Detection in Python

An internal outlier is an unusual data item located within the overall range of a multimodal distribution or a sparse gap between dense regions.

A local outlier is unusual relative to comparable nearby records, even though it resembles them more than it resembles the dataset as a whole. A global outlier, by contrast, is distinct from most records and may represent a different type of item. The distinction is clearest in data with at least two dimensions, although clustered one-dimensional data can also raise it. section 2.7

Unusual within a familiar type

Among pictures mostly showing dogs, cats, and hamsters, a dog photographed at an unusual angle is a local outlier; a parrot is a global outlier. In transaction data, an unusual purchase can be local relative to other purchases, while a rare type of transaction can be global. section 2.7

Figure 2.17 Point A is a local outlier and point B is a global outlier. Point A appears to be the same type of record as the cluster it is near but is distinct from it, while point B is not comparable to other points at all.

The diagram contrasts a point distinct from its nearby cluster with a point distinct from the dataset more broadly. section 2.7

When clusters meaningfully represent different record types, a point near a cluster’s edge can be treated as a local outlier. Comparing it with its own cluster may be more useful than comparing it with unrelated clusters. This depends on finding meaningful clusters; neighborhood-based methods instead compare records with nearby points. Detector choice and parameter tuning affect which kind of outlier is flagged, and some cases lie between local and global. section 3.2.3 section 2.7

Do not confuse *local* with *internal*. An internal outlier is a rare value within the overall range of a distribution, such as a purchase near $100 when purchases usually cluster near $10 or $500. Histograms, kernel density estimation, and nearest-neighbor calculations can find sparse regions within a single feature; being internal does not by itself establish that a record is locally unusual relative to comparable records across features. section 2.1.6 section 2.7

How Outlier Detection in Python covers it

How deep it goes
Defines the distinction with examples and cluster-based comparisons, while noting that real cases can fall between the two categories.
Examples
Contrasts an unusually photographed dog with a parrot and an unusual purchase with a rare transaction type.
What it assumes
Assumes familiarity with records and features, but defines local versus global outliers through concrete comparisons.
What you can do after
Evaluate/understand whether a flagged record differs from its relevant peers or represents a distinct type, without assuming every case is clear-cut.
How it connects
Connects local outliers to global outliers, clustering, nearest-neighbor methods, and in-distribution outliers; distinguishes them from internal outliers.

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.