Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Chains along the data, and tails of each feature
Two very different ideas share this page. COF asks how a point connects to its neighbours. Points on a thin line of data reach each other by short hops along the line, while a point sitting beside the line needs one long hop to join it. ECOD and COPOD ignore neighbours completely. For each feature they ask what fraction of the data is at least this extreme, and they add up the rarity across features, like reading several percentile charts at once.
Trajectories, pipelines and sensor sweeps produce data along curves, where density-based detectors such as LOF are confused, so COF-style connectivity helps. At the other extreme, fleet-scale tabular data needs detectors with no tuning, linear cost and per-feature explanations, which is what ECOD and COPOD were built for. Both families have blind spots worth knowing before deployment.
- 1. COF measures…
- 2. ECOD scores each feature by…
- 3. Like HBOS, ECOD and COPOD are blind to anomalies that…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Chains and tails by hand
Set-based nearest path (COF). Start with the set S = p. Repeatedly add the neighbour of p, from its k-NN set, that is closest to any point already in S, and record that edge length. For the 1-D points 0, 1, 2, 4 with p = 0 and neighbours 1, 2, 4, the edges are 1 (to 1), 1 (to 2) and 2 (to 4).
Average chaining distance. ac-dist(p) = Σᵢ wᵢ eᵢ with wᵢ = 2(k + 1 − i)/(k(k + 1)), so early edges count most.
- For k = 4 the weights are 0.4, 0.3, 0.2 and 0.1, summing to 1.
- With k = 3 the weights are 1/2, 1/3 and 1/6. The example above gives ac-dist = 0.5 + 0.333 + 0.333 = 1.167.
COF. COF(p) = ac-dist(p) divided by the average ac-dist of p’s k neighbours. About 1 means “connected like its neighbours”; well above 1 is outlying. An ac-dist of 2 against neighbours averaging 1 gives COF = 2.
Empirical CDF tails (ECOD). For feature j:
- left tail F_j(x) = fraction of the sample ≤ x;
- right tail F̄_j(x) = fraction ≥ x.
For 3, 1, 2, 2 the left tails are 1, 0.25, 0.75, 0.75 and the right tails 0.25, 1, 0.75, 0.75.
Aggregation. O_left = −Σ_j log F_j and O_right = −Σ_j log F̄_j. O_auto uses, per feature, the left tail if the feature is left-skewed and the right tail otherwise. ECOD = max(O_left, O_right, O_auto).
- Tail probabilities 0.01 and 0.5 give −log 0.01 − log 0.5 = 5.30.
- COPOD uses the same pieces as max(O_auto, (O_left + O_right)/2) in the standard (PyOD) implementation.
- 1. The SBN path adds next the neighbour closest to…
- 2. COF's chaining weights…
- 3. ECOD's automatic tail choice depends on each feature's…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.What each family sees
COF versus LOF. LOF compares density. A point next to a sparse line has a neighbourhood about as spread out as the line’s own points, so LOF ≈ 1. COF’s path from that point must start with the long hop to the line, then continue with short steps along it. Weighting early edges heavily makes its ac-dist larger than its neighbours’.
ECOD and COPOD. Empirical tail probabilities need no bandwidth, no bins and no distances; computing them costs one sort per feature, O(n d log n). Each feature’s contribution, −log(tail probability), says directly “this value is in the top 0.1% of feature j”. The aggregation is a sum over features, so, like HBOS, the score is a product of marginal evidence: correlation-breaking anomalies with ordinary marginal values are invisible.
COPOD’s copula view. Transforming each feature by its empirical CDF gives uniform marginals, the empirical copula. COPOD scores tail probabilities of these copula coordinates. It never models the copula’s dependence structure, which is why it shares the independence blind spot despite the name.
Exercise 1:
- on 6-D Gaussian data with 10 anomalies shifted by 5 in one feature, ECOD reached AUC 0.953 with no parameters;
- on 300 points along a thin line with 8 outliers beside it, COF and LOF both reached 1.000.
That line was dense enough for both; exercise 2 makes it sparse.
from pyod.models.ecod import ECOD
from pyod.models.copod import COPOD
from pyod.models.cof import COF
s = ECOD().fit(X).decision_scores_ # per-feature explanation: ECOD().explain_outlier(i)- 1. ECOD's cost is dominated by…
- 2. COPOD transforms features to…
- 3. Does COPOD model dependence between features?
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
COF’s design. Tang et al. define the SBN path to capture isolativity, the degree to which a point is connected to others, separately from density. The decreasing weights in ac-dist emphasise how a point first attaches to the data. For points inside a line-shaped cluster the path edges are uniform; for a point beside it, the first edge is long. Its cost is O(n k²) on top of the k-NN search.
Tail probabilities and p-values. For one feature, F_j(x) is an empirical one-sided p-value, the fraction at least as extreme. Under independence, −Σ log pᵢ resembles Fisher’s method for combining p-values (which uses −2Σ log pᵢ ~ χ²₂d). ECOD and COPOD use it as a score without calibration, and the max over left, right and skew-chosen aggregates guards against picking the wrong tail.
Benchmarks and caveats. On large benchmark suites (ADBench, Han et al., 2022), ECOD and COPOD are competitive and very fast, with no hyperparameters, but no unsupervised detector dominates. Their performance tracks how often benchmark anomalies are marginally extreme.
Interview questions.
- When would you choose ECOD? For a large tabular dataset needing a no-tuning baseline with per-feature explanations, where anomalies are likely extreme in some measured variable.
- When would you choose COF over LOF? When normal data lie along low-dimensional curves (trajectories, sweeps, chains of states) and the anomalies sit off those curves at comparable density.
- 1. −Σ log pᵢ across features resembles…
- 2. COF's extra cost beyond the k-NN search is about…
- 3. In large benchmarks, ECOD and COPOD are…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Marginal, relational and shape anomalies
History.
- J. Tang, Z. Chen, A. Fu and D. Cheung (2002) introduced COF.
- Z. Li, Y. Zhao, N. Botta, C. Ionescu and X. Hu (2020) introduced COPOD.
- Z. Li, Y. Zhao, X. Hu, N. Botta, C. Ionescu and G. Chen (2022) introduced ECOD.
- S. Han et al. (2022) built ADBench, benchmarking 30 detectors on 57 datasets.
Exercise 2. About 300–400 points and 8–10 anomalies of each kind, 3 datasets each. The table gives AUC (k = 10 for LOF and COF).
| anomalies… | ECOD | COPOD | LOF | COF |
|---|---|---|---|---|
| extreme in one feature (6-D) | 0.910 | 0.883 | 0.992 | 0.958 |
| breaking a correlation (2-D, ρ = 0.95) | 0.283 | 0.465 | 0.993 | 0.892 |
| 1.0 beside a sparse line, near a dense blob | 0.934 | 0.951 | 0.203 | 0.707 |
- ECOD and COPOD were worse than chance on correlation-breaking anomalies, the same blind spot as HBOS. ECOD’s 0.283 means the anomalies, with moderate values in both features, scored below many normal points in the tails.
- On the sparse line, LOF failed (0.203) because the outliers beside the line were as dense as the line’s own points, and the line’s endpoints scored higher. COF’s chaining view recovered 0.707.
- ECOD and COPOD did well on the line data (0.93–0.95), but for an incidental reason: the outliers’ y-values (±1) fall in a gap of the y distribution, between the line at 0 and the blob at 4, and below everything else. That is a marginal coincidence, not shape awareness.
- On marginal anomalies, the parameter-free tail methods were good but not the best here (0.91 against 0.99 for LOF on this small 6-D set).
These detectors in AI, robotics and aerospace
- Trajectory monitoring with COF: flag aircraft or robot states that leave the usual path through state space even when local density is similar.
- Fleet-scale tabular screening with ECOD: parameter-free scores with per-feature explanations for thousands of engines or vehicles, where no one can tune a detector per asset.
- Hybrid pipelines: ECOD for marginal extremes, plus a relational check (robust Mahalanobis on residuals, or Isolation Forest) for broken correlations.
References
- J. Tang, Z. Chen, A. W. Fu, D. W. Cheung (2002). “Enhancing effectiveness of outlier detections for low density patterns.” Proc. PAKDD.
- Z. Li, Y. Zhao, N. Botta, C. Ionescu, X. Hu (2020). “COPOD: copula-based outlier detection.” Proc. IEEE ICDM.
- Z. Li, Y. Zhao, X. Hu, N. Botta, C. Ionescu, G. H. Chen (2022). “ECOD: unsupervised outlier detection using empirical cumulative distribution functions.” IEEE Transactions on Knowledge and Data Engineering 35(12).
- S. Han, X. Hu, H. Huang, M. Jiang, Y. Zhao (2022). “ADBench: anomaly detection benchmark.” Advances in NeurIPS 35.