OPTICS

Machine Learning
Introduced by
Ankerst, M.; Breunig, M. M.; Kriegel, H.-P.; Sander, J.
Year
1999
Type
Density-based clustering (reachability ordering)

What does it do?

OPTICS (Ordering Points To Identify the Clustering Structure) is a density-based clustering algorithm introduced by Ankerst, Breunig, Kriegel, and Sander in 1999.

It generalizes DBSCAN by producing an ordering of the data that encodes its density-based cluster structure across a range of density levels, rather than a single partition for one fixed global density threshold. Clusters of varying density can be read from a reachability plot.

The intuition behind the method

Imagine walking through a set of points, always stepping to the nearest unvisited point that is reachable from a sufficiently dense point. The distance you must stretch to reach each next point, the reachability distance, is recorded as you walk. Plotting those recorded distances in walk order gives a reachability plot: valleys correspond to dense groups of points, and the peaks between valleys mark sparser regions that separate clusters. Because the ordering is computed once, the valleys at different density levels can be examined from the same run, whereas DBSCAN would have to be rerun for each epsilon setting of interest.

History

OPTICS was published in 1999 in ACM SIGMOD Record by Mihael Ankerst, Markus Breunig, Hans-Peter Kriegel, and Jörg Sander. Kriegel and Sander had also co-authored DBSCAN (Ester, Kriegel, Sander, and Xu, 1996). OPTICS was motivated by the difficulty of choosing a single global density parameter, which can fail when a dataset contains clusters at several density levels. Instead of a direct partition, it produces an ordering of the data whose reachability distances summarize the density-based cluster structure over a range of parameter settings.

When to use it

Use OPTICS when the dataset contains clusters of varying local density that a single global epsilon, as in DBSCAN, cannot capture at the same time, or when you want to inspect the density structure before choosing an extraction threshold. It suits spatial, geographic, or other point-cloud data where cluster shapes are arbitrary and noise is present. OPTICS assumes that meaningful clusters are denser than the surrounding space, that a meaningful distance metric exists for the data, and that minPts can be chosen from domain knowledge. It is not a good choice when all clusters are known to have similar density (standard DBSCAN is then simpler), when the dataset is very large and no efficient spatial index is available, or when the data are purely categorical with no coherent distance measure.

Limitations and considerations

  • The reachability plot and xi-steep extraction require judgement to interpret, and the choice of xi and minPts affects the extracted clusters.
  • Computational complexity is O(n log n) when a spatial index such as a k-d tree or ball tree is used, but O(n²) without one, which limits use on very large datasets.
  • Density estimates become unreliable in high-dimensional spaces, where pairwise distances tend to concentrate and density differences are harder to detect.
  • The algorithm still requires two parameters, epsilon and minPts; epsilon plays a secondary role, but a poor choice can still distort the reachability plot.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Handles clusters of varying density within a single run, which addresses the main limitation of DBSCAN's single global epsilon.
  • Does not require the number of clusters to be specified in advance.
  • Identifies noise points explicitly rather than forcing every point into a cluster.
  • The reachability plot gives a visual summary of the density structure that can be inspected before choosing an extraction method.
  • Cluster extraction can be repeated at different thresholds after the ordering is computed, without rerunning the ordering step.

Applications

  • Spatial and geographic data analysis, such as identifying regions of high event density (for example crime hotspots or species habitats) at several spatial scales.
  • Anomaly and noise detection in sensor, network, and IoT data.
  • Image segmentation and object detection where groups of pixels differ in local density.
  • Bioinformatics, for example clustering gene expression profiles where natural groupings differ in compactness.
  • Exploratory data analysis as a step before other methods, to understand the density landscape of the data.

How it works

How it works

1

Let N_epsilon(p) be the set of objects within distance epsilon of p, counting p itself, as in the standard textbook example. If |N_epsilon(p)| < minPts, p is not a core point and its core distance is undefined. Otherwise the core distance is the distance from p to its minPts-th nearest object, counting p itself. For example, with minPts = 5 this is the distance to the fourth closest other object. The core distance captures the local density around p: a small value means p sits in a dense region.

Formula
\text{core-dist}_{\varepsilon,\text{minPts}}(p) = \begin{cases} \text{UNDEFINED} & |N_\varepsilon(p)| < \text{minPts} \\ d_{\text{minPts}}(p) & \text{otherwise} \end{cases}
2

The reachability distance from a point p to an already-processed core point o is the larger of two quantities: the core distance of o and the actual distance between p and o under the chosen metric. Taking the core distance as a floor smooths the values inside dense regions, so that sparse chains of points there do not produce spurious small reachability values. A point may be reachable from several core points; the smallest reachability distance found is the one kept, because it describes the shortest connection to a dense region.

Formula
\text{reach-dist}_{\varepsilon,\text{minPts}}(p, o) = \max\!\left(\text{core-dist}_{\varepsilon,\text{minPts}}(o),\; d(p, o)\right)
3

OPTICS maintains a priority queue (seeds) ordered by reachability distance. It starts from an unvisited point, marks it processed, and inserts or updates its neighbors in the seeds queue. The neighbor with the smallest current reachability distance is extracted next, and the process repeats until every point is processed. The sequence in which points are extracted defines the OPTICS ordering.

4

After ordering all points, their reachability distances are plotted in that order. Dense clusters appear as valleys (low reachability distances) separated by peaks (high distances corresponding to sparse regions). Points with high reachability, which are not closely reached from any dense region, appear as peaks and are candidates for noise. Whether they are finally labelled noise depends on the extraction threshold or xi chosen. The plot is the primary output of OPTICS and allows visual inspection of the cluster structure.

5

Clusters are extracted from the reachability plot either by thresholding at a chosen epsilon' or by the xi-steep method. In the xi-steep method, xi is a relative steepness between 0 and 1. A valley is delimited by a steep downward area and a later steep upward area, in which reachability falls or rises by at least the relative proportion given by xi. Larger xi values keep only sharper density changes. The method needs no absolute distance threshold, but xi should be checked against the reachability plot. A horizontal threshold epsilon' recovers a DBSCAN-like result only when epsilon' does not exceed the epsilon used to generate the ordering.

Formula
\xi\text{-steep descent/ascent: } \frac{\text{reach}(p_{i+1})}{\text{reach}(p_i)} \leq 1 - \xi \;\text{ (descent)},\quad \frac{\text{reach}(p_{i+1})}{\text{reach}(p_i)} \geq \frac{1}{1 - \xi} \;\text{ (ascent)}

Common pitfalls

  • Setting epsilon too small truncates the neighborhoods, so most points lose their core distances and are labelled noise.
  • Using a very small minPts (for example 2 or 3) makes the result sensitive to noise and can produce spurious micro-clusters.
  • Treating the flat clusters from one threshold as the full result without inspecting the reachability plot for nested sub-clusters.
  • Choosing an extraction threshold epsilon' larger than the epsilon used to compute the ordering, which falls outside the range where the result matches DBSCAN.
  • Applying OPTICS to categorical or mixed-type data without a carefully defined dissimilarity measure.
  • Skipping normalization or standardization when features are on very different scales, which distorts the distance-based density estimates.

Frequently asked questions

How does OPTICS differ from DBSCAN?

DBSCAN partitions the data using a fixed epsilon and minPts, so it finds clusters at one density level per run. OPTICS computes an ordering with reachability distances that encodes the density-based clustering across a range of epsilon values. Clusters can then be extracted at a chosen threshold, which corresponds to a DBSCAN-like result when that threshold does not exceed the epsilon used to compute the ordering, or automatically with the xi-steep method.

How should I choose minPts and epsilon?

Choose minPts from domain knowledge about the smallest group that should count as a cluster; larger values smooth out noise but can merge small clusters. A value such as 5 is only an illustrative setting, not a recommended default. Set epsilon large enough that neighborhoods are not truncated, keeping in mind that a large epsilon increases the cost of neighbor searches, especially without a spatial index. Inspect the reachability plot and adjust the extraction threshold or xi, rather than tuning epsilon alone.

How do I extract concrete clusters from the reachability plot?

Two main approaches exist. The simpler one applies a horizontal threshold epsilon' to the reachability plot: points with reachability distance below epsilon' are grouped into clusters, with epsilon' not larger than the epsilon used for the ordering. The xi-steep approach, with xi between 0 and 1, identifies valleys bounded by steep descents and ascents in reachability distance of at least the relative proportion xi. It avoids an absolute distance threshold, but xi should be checked against the plot. Noise labels depend on the threshold or xi chosen.

Is OPTICS suitable for high-dimensional data?

With caution. In high dimensions, pairwise distances tend to concentrate, which makes density differences harder to detect. Dimensionality reduction or a distance measure suited to the domain can be applied before OPTICS to mitigate this. Related density-based methods such as HDBSCAN are also used in this setting and are covered on their own pages.

Related methods

Sources

  1. Ankerst, M., Breunig, M. M., Kriegel, H.-P., & Sander, J. (1999). OPTICS: Ordering points to identify the clustering structure. ACM SIGMOD Record, 28(2), 49–60.

    Open DOI reference
  2. Ester, M., Kriegel, H.-P., Sander, J., & Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. Proceedings of the 2nd International Conference on Knowledge Discovery and Data Mining (KDD-96), 226–231.

    Open publication reference
  3. Aggarwal, C. C., & Reddy, C. K. (Eds.) (2013). Data Clustering: Algorithms and Applications (Ch. 4). CRC Press.

    ISBN: 978-1-4665-5821-2