Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A landscape of density
Instead of answering “which cluster is each point in?” for one ε, OPTICS walks through the data, always stepping to the closest unvisited point it can reach. It writes down how far each step was. Plot those step sizes in visiting order and you get a landscape: valleys are clusters (many short steps) and peaks are the jumps between them. Drawing a horizontal line at height ε and reading off the valleys below it gives DBSCAN’s answer for that ε, for any ε, from a single run.
The reachability plot is a one-picture summary of density structure at all scales. It shows whether there are clusters inside clusters, how separated they are, and which parameter range is sensible. Analysts use it to explore telemetry or trajectory data before committing to parameters, and scikit-learn’s OPTICS extracts clusters from it automatically.
- 1. In a reachability plot, clusters appear as…
- 2. A horizontal cut at ε gives…
- 3. How many OPTICS runs give clusterings for many ε?
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Distances by hand
Core distance (minPts = 3, the point itself counts). For points 0, 1, 3, 7 the distances to the 3rd closest point are 3, 2, 3, 6.
Reachability distance of q from p: max(core(p), d(p, q)). With core(p) = 2:
- a point at distance 1 has reachability 2, because inside p’s core radius everything is “equally reachable”;
- a point at distance 5 has reachability 5.
Extracting at ε. Walk the ordering:
- if reach > ε and core ≤ ε, the point starts a new cluster;
- if reach > ε and core > ε, it is noise;
- otherwise it joins the current cluster.
With order (0, 1, 2, 3, 4), reach = (∞, 0.2, 0.3, 2.0, 0.25) and core = (0.2, 0.2, 0.3, 0.3, 0.25):
- ε = 0.5 gives labels 0, 0, 0, 1, 1;
- ε = 0.22 gives 0, 0, noise, noise, noise.
The steps in plain English:
- Compute every point’s core distance.
- Start at any unprocessed point. Output it, and update its neighbours’ reachability to max(core(p), d(p, q)) if that is smaller than what they had.
- Next output the unprocessed point with the smallest reachability, using a priority queue. When the queue empties, start again from any unprocessed point, with reachability ∞.
- Plot reachability in output order. Read clusters as valleys, or cut at ε for a DBSCAN-equivalent result.
- 1. Reachability of q from p when core(p) = 3 and d(p, q) = 1?
- 2. During extraction, a point with reach > ε and core > ε is…
- 3. The first point output in each run has reachability…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Reading the plot, and extraction
Equivalence with DBSCAN. The ordering visits each dense region completely before jumping to another, so cutting the reachability plot at ε recovers DBSCAN’s clustering at ε, given ε at most the generating radius (infinite here). Exercise 1: one OPTICS run gave exactly DBSCAN’s partition of the core points at ε = 0.05, 0.1, 0.2 and 0.4. Border points differed in at most 0.23% of point pairs, because border assignment is order-dependent in both algorithms.
Mixed densities in the plot. Two tight blobs make deep, narrow valleys separated by a sharp peak. A sparse blob makes a shallow, wide valley. No horizontal line separates the deep pair and keeps the shallow one whole (the demo shows this). The plot still shows all three clusters to the eye, which is why better extraction methods exist:
- ξ-steep areas: a cluster starts where reachability drops by at least a fraction ξ and ends where it rises again;
- Cluster trees built from significant local maxima (Sander et al., 2003).
Both read clusters at different heights.
minPts. Small minPts gives a spiky plot. Large minPts smooths it but shrinks the contrast between valleys and peaks. In exercise 2, going from minPts = 2 to 40 cut the median relative jump inside clusters from 0.35 to 0, but the peak between the tight blobs fell from 11.5× to 2.8× the valley floor.
from sklearn.cluster import OPTICS, cluster_optics_dbscan
op = OPTICS(min_samples=5, xi=0.05).fit(X) # ξ extraction
plot = op.reachability_[op.ordering_]
labels_at_eps = cluster_optics_dbscan(reachability=op.reachability_, core_distances=op.core_distances_,
ordering=op.ordering_, eps=0.2)- 1. Cutting the reachability plot at ε reproduces DBSCAN exactly for…
- 2. ξ extraction finds clusters by…
- 3. Increasing minPts makes the plot…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why the ordering works. At each step OPTICS outputs the unprocessed point with the smallest reachability from the processed set: Prim’s algorithm on the reachability “distance”. So the ordering traces a minimum spanning structure of the density-scaled graph. Each dense region is finished before a larger jump is taken, which places every DBSCAN cluster as a contiguous run in the order.
Relation to HDBSCAN. OPTICS reachability is asymmetric (it uses only core(p)). HDBSCAN’s mutual reachability is the symmetric version, max(core(p), core(q), d). Both encode the full density hierarchy. HDBSCAN adds the condensed tree and stability-based selection that OPTICS leaves to extraction heuristics.
Cost. OPTICS needs one ε-range query per point plus heap operations, O(n log n) with an index in low dimension and O(n²) otherwise. The generating radius ε_max bounds query cost and can be set large.
Interview questions.
- What does OPTICS add over DBSCAN? A full density landscape from one run, the ability to see nested and varying-density clusters, and DBSCAN at any ε without rerunning.
- How do you get clusters from OPTICS? Cut at ε (DBSCAN-equivalent), use ξ-steep extraction, or build a cluster tree from the plot’s significant maxima.
- 1. OPTICS's ordering is like…
- 2. HDBSCAN's mutual reachability differs by…
- 3. OPTICS cost with a spatial index in low dimension?
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.What does minPts do to the reachability plot?
History.
- M. Ankerst, M. Breunig, H.-P. Kriegel and J. Sander introduced OPTICS at SIGMOD 1999, together with ξ extraction.
- J. Sander, X. Qin, Z. Lu, N. Niu and A. Kovarsky (2003) built cluster trees automatically from reachability plots.
- R. Campello et al. (2013) connected OPTICS-style reachability to HDBSCAN.
Exercise 2. Two tight blobs and one sparse blob, 3 datasets, plotted in OPTICS order.
- Jump is the median relative change between consecutive reachabilities inside the tight blobs.
- Peak ÷ floor is the reachability where the order enters the second tight blob, divided by the tight blobs’ median reachability.
- Best cut ARI is the best single horizontal cut.
| minPts | jump | peak ÷ floor | best cut ARI |
|---|---|---|---|
| 2 | 0.351 | 11.48 | 0.807 |
| 5 | 0.023 | 8.08 | 0.782 |
| 10 | 0.004 | 5.81 | 0.733 |
| 20 | 0.000 | 4.13 | 0.728 |
| 40 | 0.000 | 2.84 | 0.724 |
- minPts smooths the plot dramatically. Above minPts ≈ 10 consecutive values are often identical, because reachability is clamped by the core distance.
- It also flattens the separating peak. That is a trade-off between a readable plot and visible separation.
- No single cut reached 0.85 ARI at any minPts. OPTICS plus a horizontal cut is still DBSCAN. The benefit comes from reading the plot at several levels.
OPTICS in AI, robotics and aerospace
- Exploratory analysis of trajectory, radar or telemetry data: the reachability plot reveals nested structure before you choose parameters.
- Hotspot hierarchies: dense cores (airports) within broader regions (terminal areas).
- Anomaly context: points with consistently high reachability are isolated in every density view.
References
- M. Ankerst, M. M. Breunig, H.-P. Kriegel, J. Sander (1999). “OPTICS: ordering points to identify the clustering structure.” Proc. ACM SIGMOD.
- J. Sander, X. Qin, Z. Lu, N. Niu, A. Kovarsky (2003). “Automatic extraction of clusters from hierarchical clustering representations.” Proc. PAKDD.
- R. J. G. B. Campello, D. Moulavi, J. Sander (2013). “Density-based clustering based on hierarchical density estimates.” Proc. PAKDD.
- E. Schubert, M. Gertz (2018). “Improving the cluster structure extracted from OPTICS plots.” Proc. LWDA.
- scikit-learn developers. “OPTICS.” Documentation.